MCPcopy
hub / github.com/mudler/LocalAI / sendSessionUpdate

Function sendSessionUpdate

core/http/static/talk.js:160–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

158
159// Send a session.update event with the user's settings
160function sendSessionUpdate() {
161 if (!dc || dc.readyState !== 'open') return;
162
163 const instructions = document.getElementById('instructionsInput').value.trim();
164 const voice = document.getElementById('voiceInput').value.trim();
165 const language = document.getElementById('languageInput').value.trim();
166
167 // Only send if the user configured something
168 if (!instructions && !voice && !language) return;
169
170 const session = {};
171
172 if (instructions) {
173 session.instructions = instructions;
174 }
175
176 if (voice || language) {
177 session.audio = {};
178 if (voice) {
179 session.audio.output = { voice: voice };
180 }
181 if (language) {
182 session.audio.input = {
183 transcription: { language: language }
184 };
185 }
186 }
187
188 const event = {
189 type: 'session.update',
190 session: session,
191 };
192
193 console.log('[session.update]', event);
194 dc.send(JSON.stringify(event));
195}
196
197function handleServerEvent(event) {
198 console.log('[event]', event.type, event);

Callers 2

handleServerEventFunction · 0.85
TalkFunction · 0.85

Calls 3

stringifyMethod · 0.80
logMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected