-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCiceroBot.js
More file actions
39 lines (35 loc) · 824 Bytes
/
CiceroBot.js
File metadata and controls
39 lines (35 loc) · 824 Bytes
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
import { test } from 'backend/myScript';
import { chGenerate } from 'backend/myScript';
var chat = Array()
$w.onReady(function () {
chat.push(" Hi! How are you?")
});
$w('#button1').onClick(function (){
console.log("clicked")
chat.push(" " + $w('#textBox1').value)
var prompt=""
for (var i = Math.max(0,chat.length-3); i < chat.length; i++) {
if (i%2==0){
prompt+="Therapist:"
}
else{
prompt+="Student:"
}
prompt+=chat[i] +"\n"
}
prompt+= "\nTherapist:"
chGenerate(prompt).then(function(product) {
chat.push(" "+product.body.generations[0].text.slice(0,-1))
var display=""
for (var j = 0; j < chat.length; j++) {
if (j%2==0){
display+="CiceroBot:"
}
else{
display+="You:"
}
display+=chat[j] +"\n"
}
$w('#text19').text = display
});
})