forked from codio-extensions/coach-callback-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (55 loc) · 2.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
window.codioIDE.coachBot.register('customButton1', 'More...', () => {
window.codioIDE.coachBot.showButton('react hook docs', async () => {
const context = await window.codioIDE.coachBot.getContext()
console.log('coach bot context', context)
const input = await window.codioIDE.coachBot.input('please type hook name')
window.codioIDE.coachBot.ask({userPrompt: input, systemPrompt: 'get react hook docs for user provided hook'})
})
window.codioIDE.coachBot.showButton('react hook docs not stream', async () => {
window.codioIDE.coachBot.write('see result in dev console')
const input = await window.codioIDE.coachBot.input('please type hook name')
const data = await window.codioIDE.coachBot.ask({
userPrompt: input,
systemPrompt: 'get react hook docs for user provided hook'
}, {stream: false})
console.log('not stream coach responce', data)
})
})
window.codioIDE.menu.addItem(
{id: 'education'},
{id: 'customId1', title: 'Open coach(call custom)', callback: () => {
window.codioIDE.coachBot.open({id: 'customButton1'})
}}
)
window.codioIDE.menu.addItem(
{id: 'education'},
{id: 'customId2', title: 'call custom coach action', callback: () => {
window.codioIDE.coachBot.call({id: 'customButton1'})
}}
)
window.codioIDE.menu.addItem(
{id: 'education'},
{id: 'customId3', title: 'Close coach', callback: () => {
window.codioIDE.coachBot.close()
}}
)
window.codioIDE.menu.addItem(
{id: 'education'},
{id: 'customId4', title: 'show coach tooltip', callback: () => {
window.codioIDE.coachBot.showTooltip('click me to call custom action', () => {
window.codioIDE.coachBot.call({id: 'customButton1'})
})
}}
)
window.codioIDE.menu.addItem(
{id: 'education'},
{id: 'customId5', title: 'hide coach tooltip', callback: () => {
window.codioIDE.coachBot.hideTooltip()
}}
)
window.codioIDE.menu.addItem(
{id: 'education'},
{id: 'customId6', title: 'deregister custom action', callback: () => {
window.codioIDE.coachBot.deregister('customButton1')
}}
)