generated from environment-safe/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
234 lines (219 loc) · 10.6 KB
/
demo.html
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loading...</title>
<style>
body{
padding: 0px;
margin: 0px;
width:100%;
height: 100%;
overflow: scroll;
}
#chat{
}
#forkme{
position: absolute;
top: 0px;
right: 0px;
display: block;
}
/** ios1-ios6 bubbles **/
.bubble {
box-sizing: border-box;
float: left;
width: auto;
max-width: 80%;
position: relative;
clear: both;
background: #95c2fd;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.15, #bee2ff), color-stop(1, #95c2fd));
background-image: -webkit-linear-gradient(bottom, #bee2ff 15%, #95c2fd 100%);
background-image: -moz-linear-gradient(bottom, #bee2ff 15%, #95c2fd 100%);
background-image: -ms-linear-gradient(bottom, #bee2ff 15%, #95c2fd 100%);
background-image: -o-linear-gradient(bottom, #bee2ff 15%, #95c2fd 100%);
background-image: linear-gradient(bottom, #bee2ff 15%, #95c2fd 100%);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#95c2fd', endColorstr='#bee2ff');
border: solid 1px rgba(0,0,0,0.5);
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
-webkit-box-shadow: inset 0 8px 5px rgba(255,255,255,0.65), 0 1px 2px rgba(0,0,0,0.2);
-moz-box-shadow: inset 0 8px 5px rgba(255,255,255,0.65), 0 1px 2px rgba(0,0,0,0.2);
box-shadow: inset 0 8px 5px rgba(255,255,255,0.65), 0 1px 2px rgba(0,0,0,0.2);
margin-bottom: 20px;
padding: 6px 20px;
color: #000;
text-shadow: 0 1px 1px rgba(255,255,255,0.8);
word-wrap: break-word;
}
.bubble:before, .bubble:after {
border-radius: 20px / 5px;
content: '';
display: block;
position: absolute;
}
.bubble:before {
border: 10px solid transparent;
border-bottom-color: rgba(0,0,0,0.5);
bottom: 0px;
left: -7px;
z-index: -2;
}
.bubble:after {
border: 8px solid transparent;
border-bottom-color: #bee2ff; /* arrow color */
bottom: 1px;
left: -5px;
}
.bubble-alt {
float: right;
}
.bubble-alt:before {
left: auto;
right: -7px;
}
.bubble-alt:after {
left: auto;
right: -5px;
}
.bubble p {
font-size: 1.4em;
}
/* green bubble */
.green {
background: #7acd47;
background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.15, #ace44b),color-stop(1, #7acd47));
background-image: -webkit-linear-gradient(bottom, #ace44b 15%, #7acd47 100%);
background-image: -moz-linear-gradient(bottom, #ace44b 15%, #7acd47 100%);
background-image: -ms-linear-gradient(bottom, #ace44b 15%, #7acd47 100%);
background-image: -o-linear-gradient(bottom, #ace44b 15%, #7acd47 100%);
background-image: linear-gradient(bottom, #ace44b 15%, #7acd47 100%);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#7acd47', endColorstr='#ace44b');
}
.green:after {
border-bottom-color: #ace44b;
}
/* white bubble */
.white {
background: #7acd47;
background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.15, #e5e5e5),color-stop(1, #dbdbdb));
background-image: -webkit-linear-gradient(bottom, #e5e5e5 15%, #dbdbdb 100%);
background-image: -moz-linear-gradient(bottom, #e5e5e5 15%, #dbdbdb 100%);
background-image: -ms-linear-gradient(bottom, #e5e5e5 15%, #dbdbdb 100%);
background-image: -o-linear-gradient(bottom, #e5e5e5 15%, #dbdbdb 100%);
background-image: linear-gradient(bottom, #e5e5e5 15%, #dbdbdb 100%);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#dbdbdb', endColorstr='#e5e5e5');
}
.white:after {
border-bottom-color: #e5e5e5;
}
/* yellow bubble */
.yellow {
background: #7acd47;
background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.15, #fcf3c3),color-stop(1, #f4e371));
background-image: -webkit-linear-gradient(bottom, #fcf3c3 15%, #f4e371 100%);
background-image: -moz-linear-gradient(bottom, #fcf3c3 15%, #f4e371 100%);
background-image: -ms-linear-gradient(bottom, #fcf3c3 15%, #f4e371 100%);
background-image: -o-linear-gradient(bottom, #fcf3c3 15%, #f4e371 100%);
background-image: linear-gradient(bottom, #fcf3c3 15%, #f4e371 100%);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#f4e371', endColorstr='#fcf3c3');
}
.yellow:after {
border-bottom-color: #fcf3c3;
}
/* red bubble */
.red {
background: #7acd47;
background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.15, #ea8378),color-stop(1, #e2675a));
background-image: -webkit-linear-gradient(bottom, #ea8378 15%, #e2675a 100%);
background-image: -moz-linear-gradient(bottom, #ea8378 15%, #e2675a 100%);
background-image: -ms-linear-gradient(bottom, #ea8378 15%, #e2675a 100%);
background-image: -o-linear-gradient(bottom, #ea8378 15%, #e2675a 100%);
background-image: linear-gradient(bottom, #ea8378 15%, #e2675a 100%);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#e2675a', endColorstr='#ea8378');
}
.red:after {
border-bottom-color: #ea8378;
}
/* pink bubble */
.pink {
background: #7acd47;
background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.15, #ffbee3),color-stop(1, #f8a5ce));
background-image: -webkit-linear-gradient(bottom, #ffbee3 15%, #f8a5ce 100%);
background-image: -moz-linear-gradient(bottom, #ffbee3 15%, #f8a5ce 100%);
background-image: -ms-linear-gradient(bottom, #ffbee3 15%, #f8a5ce 100%);
background-image: -o-linear-gradient(bottom, #ffbee3 15%, #f8a5ce 100%);
background-image: linear-gradient(bottom, #ffbee3 15%, #f8a5ce 100%);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#f8a5ce', endColorstr='#ffbee3');
}
.pink:after {
border-bottom-color: #ffbee3;
}
</style>
<script type="importmap">{ "imports" :{
"browser-or-node":"https://unpkg.com/[email protected]/src/index.js",
"@environment-safe/package" : "https://unpkg.com/@environment-safe/[email protected]/src/index.mjs",
"@environment-safe/speech" : "https://unpkg.com/@environment-safe/[email protected]/src/index.mjs",
"@environment-safe/event-emitter" : "https://unpkg.com/@environment-safe/[email protected]/src/index.mjs",
"@environment-safe/random" : "https://unpkg.com/@environment-safe/[email protected]/src/index.mjs",
"@environment-safe/ollama" : "https://unpkg.com/@environment-safe/[email protected]/src/index.mjs",
"@environment-safe/runtime-context" : "https://unpkg.com/@environment-safe/[email protected]/src/index.mjs",
"sift": "https://www.unpkg.com/[email protected]/es5m/index.js",
"@open-automaton/kryten" : "./src/index.mjs",
"@open-automaton/kryten/bots/kryten.mjs" : "./bots/kryten.mjs",
"@open-automaton/kryten/src/speech-io.mjs" : "./src/speech-io.mjs",
"@open-automaton/kryten/src/console-io.mjs" : "./src/console-io.mjs",
"module": "https://unpkg.com/[email protected]/src/index.js",
"node:events": "https://unpkg.com/[email protected]/node-events.mjs",
"@echogarden/macos-native-tts":"https://unpkg.com/[email protected]/src/index.js",
"path": "https://unpkg.com/[email protected]/src/index.js",
"url": "https://unpkg.com/[email protected]/src/index.js"
}}</script>
<!--<script
type="module"
src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@2/dist/zero-md.min.js"
></script>-->
<script type="module">
import { loop } from './kryten-demo.mjs';
const container = document.getElementById('chat');
const voiceList = document.getElementById('voices');
loop.listenForInput(true);
loop.on('response', (values)=>{
console.log(values);
container.innerHTML += `<div class="bubble bubble-alt green">${values.message}</div>`;
container.scrollTop = container.scrollHeight;
//window.scrollTo(0, document.body.scrollHeight);
});
loop.on('request', (values)=>{
console.log(values);
container.innerHTML += `<div class="bubble blue">${values.message}</div>`;
container.scrollTop = container.scrollHeight;
//window.scrollTo(0, document.body.scrollHeight);
});
loop.on('stop', (values)=>{
bot.say('Goodbye!');
});
loop.on('voices', ({voices})=>{
voices.forEach((voice)=>{
const el = document.createElement('option', {
value: voice.voiceURI
});
el.innerHTML = voice.name;
voiceList.appendChild(el);
});
});
loop.on('voice', ({voice})=>{
console.log('>>', voice);
});
</script>
</head>
<body>
<label for="voice">Voice</label>
<select id="voices" name="voice"><select><br>
<div id="chat"></div>
</body>
</html>