feat(geminiLive): restore systemInstruction in setup frame
This commit is contained in:
parent
2b1a354791
commit
9a62fba0f2
2 changed files with 11 additions and 9 deletions
|
|
@ -62,7 +62,7 @@ describe("openGeminiLiveSession (raw WS)", () => {
|
|||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("envoie le setup frame minimal à l'open Gemini (model + responseModalities AUDIO)", () => {
|
||||
it("envoie le setup frame avec model + responseModalities AUDIO + systemInstruction", () => {
|
||||
const client = new FakeWs();
|
||||
const gemini = new FakeWs();
|
||||
openGeminiLiveSession(client, {
|
||||
|
|
@ -75,9 +75,10 @@ describe("openGeminiLiveSession (raw WS)", () => {
|
|||
const setup = JSON.parse(gemini.sent[0] as string);
|
||||
expect(setup.setup.model).toBe(`models/${GEMINI_LIVE_MODEL}`);
|
||||
expect(setup.setup.generationConfig.responseModalities).toContain("AUDIO");
|
||||
// ⚠ DEBUG : champs volontairement absents tant que setupComplete n'est pas
|
||||
// confirmé en prod. Réintégration champ par champ ensuite.
|
||||
expect(setup.setup.systemInstruction).toBeUndefined();
|
||||
expect(setup.setup.systemInstruction.parts[0].text).toContain(
|
||||
"un bailleur qui propose un appartement",
|
||||
);
|
||||
// ⚠ DEBUG : autres champs encore absents — réintégration champ par champ.
|
||||
expect(setup.setup.inputAudioTranscription).toBeUndefined();
|
||||
expect(setup.setup.outputAudioTranscription).toBeUndefined();
|
||||
expect(setup.setup.realtimeInputConfig).toBeUndefined();
|
||||
|
|
|
|||
|
|
@ -214,13 +214,16 @@ function tryParseGeminiJson(data: unknown): GeminiServerMessage | null {
|
|||
* `realtimeInputConfig.automaticActivityDetection` sont volontairement
|
||||
* retirés tant que `setupComplete` n'est pas confirmé en prod.
|
||||
*/
|
||||
function buildSetupFrame(): string {
|
||||
function buildSetupFrame(systemPrompt: string): string {
|
||||
return JSON.stringify({
|
||||
setup: {
|
||||
model: `models/${GEMINI_LIVE_MODEL}`,
|
||||
generationConfig: {
|
||||
responseModalities: ["AUDIO"],
|
||||
},
|
||||
systemInstruction: {
|
||||
parts: [{ text: systemPrompt }],
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -256,12 +259,10 @@ export function openGeminiLiveSession(
|
|||
|
||||
const timeoutMs = opts.timeoutMs ?? T2_SESSION_TIMEOUT_MS;
|
||||
const warningMs = opts.warningMs ?? T2_SESSION_WARNING_MS;
|
||||
// Conservé en signature pour usage futur (réintégration `systemInstruction`).
|
||||
const _systemPrompt = buildT2SystemPrompt({
|
||||
const systemPrompt = buildT2SystemPrompt({
|
||||
role: opts.role,
|
||||
contexte: opts.contexte,
|
||||
});
|
||||
void _systemPrompt;
|
||||
|
||||
const url = `${GEMINI_LIVE_URL}?key=${apiKey}`;
|
||||
const factory =
|
||||
|
|
@ -312,7 +313,7 @@ export function openGeminiLiveSession(
|
|||
|
||||
geminiWs.on("open", () => {
|
||||
console.log("[T2] Gemini WS open");
|
||||
const frame = buildSetupFrame();
|
||||
const frame = buildSetupFrame(systemPrompt);
|
||||
console.log("[T2] Gemini setup frame:", frame);
|
||||
try {
|
||||
geminiWs.send(frame);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue