fix: correct WebSocket setup format and handle Blob messages
Some checks failed
Build & Push / build-and-push (push) Has been cancelled
Some checks failed
Build & Push / build-and-push (push) Has been cancelled
- Setup uses "generationConfig" field (not "config") inside "setup" object - Handle Blob data from WebSocket (Gemini sends binary, not text) - Voice agent now successfully connects and receives setupComplete Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@ interface VoiceAgentContextValue {
|
||||
endConversation: () => void;
|
||||
completedBrief: string | null;
|
||||
completedFormData: WizardFormData | null;
|
||||
debugLog: string[];
|
||||
}
|
||||
|
||||
// ─── Context ─────────────────────────────────────────────────────────────────
|
||||
@@ -289,13 +290,14 @@ export default function VoiceAgentProvider({ locale, children }: VoiceAgentProvi
|
||||
}, 10_000);
|
||||
|
||||
ws.onopen = () => {
|
||||
console.log('[VoiceAgent] WebSocket opened, sending config...');
|
||||
// Send setup message — must use "config" key per Gemini Live API spec
|
||||
console.log('[VoiceAgent] WebSocket opened, sending setup...');
|
||||
ws.send(JSON.stringify({
|
||||
config: {
|
||||
setup: {
|
||||
model: `models/${model}`,
|
||||
responseModalities: config.responseModalities,
|
||||
speechConfig: config.speechConfig,
|
||||
generationConfig: {
|
||||
responseModalities: config.responseModalities,
|
||||
speechConfig: config.speechConfig,
|
||||
},
|
||||
systemInstruction: {
|
||||
parts: [{ text: config.systemInstruction }],
|
||||
},
|
||||
@@ -320,7 +322,13 @@ export default function VoiceAgentProvider({ locale, children }: VoiceAgentProvi
|
||||
};
|
||||
|
||||
ws.onmessage = async (event) => {
|
||||
const msg = JSON.parse(event.data as string);
|
||||
let raw: string;
|
||||
if (event.data instanceof Blob) {
|
||||
raw = await event.data.text();
|
||||
} else {
|
||||
raw = event.data as string;
|
||||
}
|
||||
const msg = JSON.parse(raw);
|
||||
console.log('[VoiceAgent] Message:', JSON.stringify(msg).slice(0, 200));
|
||||
|
||||
// Setup complete — Gemini sends back a setupComplete message
|
||||
|
||||
Reference in New Issue
Block a user