From be2b325c4b7c49e6dceb5813bff10172e4df6202 Mon Sep 17 00:00:00 2001 From: Hermann_Kitio Date: Mon, 27 Apr 2026 02:48:28 +0300 Subject: [PATCH] chore(geminiLive): add detailed SDK logging for Render debug --- src/lib/geminiLive.ts | 53 +++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/lib/geminiLive.ts b/src/lib/geminiLive.ts index d38556e..e272483 100644 --- a/src/lib/geminiLive.ts +++ b/src/lib/geminiLive.ts @@ -294,26 +294,31 @@ export function openGeminiLiveSession( }; // ── Ouverture de la session SDK ────────────────────────────────────── + const sdkConfig = { + responseModalities: [Modality.AUDIO], + systemInstruction: systemPrompt, + inputAudioTranscription: {}, + outputAudioTranscription: {}, + realtimeInputConfig: { + automaticActivityDetection: { + disabled: false, + startOfSpeechSensitivity: StartSensitivity.START_SENSITIVITY_LOW, + endOfSpeechSensitivity: EndSensitivity.END_SENSITIVITY_LOW, + silenceDurationMs: 2000, + }, + }, + }; + + console.log("[T2] SDK config:", JSON.stringify(sdkConfig, null, 2)); + console.log("[T2] SDK model:", GEMINI_LIVE_MODEL); + ai.live .connect({ model: GEMINI_LIVE_MODEL, - config: { - responseModalities: [Modality.AUDIO], - systemInstruction: systemPrompt, - inputAudioTranscription: {}, - outputAudioTranscription: {}, - realtimeInputConfig: { - automaticActivityDetection: { - disabled: false, - startOfSpeechSensitivity: StartSensitivity.START_SENSITIVITY_LOW, - endOfSpeechSensitivity: EndSensitivity.END_SENSITIVITY_LOW, - silenceDurationMs: 2000, - }, - }, - }, + config: sdkConfig, callbacks: { onopen: () => { - console.log("[T2] Session Gemini ouverte (SDK)"); + console.log("[T2] Gemini SDK onopen"); // Démarrer les timers une fois la session effectivement ouverte. warningTimer = setTimeout(() => { if (sessionEnded) return; @@ -334,13 +339,14 @@ export function openGeminiLiveSession( }, timeoutMs); }, onmessage: (msg: LiveServerMessage) => { + console.log( + "[T2] Gemini SDK message:", + JSON.stringify(msg).substring(0, 200), + ); handleSdkMessage(msg); }, onerror: (err: unknown) => { - console.log( - "[T2] Erreur SDK :", - err instanceof Error ? err.message : String(err), - ); + console.log("[T2] Gemini SDK error:", JSON.stringify(err)); if (!sessionEnded) { clearTimers(); sessionEnded = true; @@ -351,8 +357,8 @@ export function openGeminiLiveSession( } } }, - onclose: () => { - console.log("[T2] Session Gemini fermée (SDK)"); + onclose: (e: unknown) => { + console.log("[T2] Gemini SDK close:", JSON.stringify(e)); if (!sessionEnded) { clearTimers(); try { @@ -368,10 +374,7 @@ export function openGeminiLiveSession( session = s; }) .catch((err: unknown) => { - console.log( - "[T2] live.connect a échoué :", - err instanceof Error ? err.message : String(err), - ); + console.error("[T2] SDK connect error:", err); sessionEnded = true; clearTimers(); try {