MCPcopy Create free account
hub / github.com/tiann/hapi / buildGeminiLiveSetupMessage

Function buildGeminiLiveSetupMessage

shared/src/voice.ts:432–464  ·  view source on GitHub ↗
(
    language?: string,
    voiceName?: string,
    systemInstruction?: string,
    options?: { affectiveDialog?: boolean }
)

Source from the content-addressed store, hash-verified

430
431/** Wire-format setup frame for Gemini Live BidiGenerateContent (hub proxy + web client). */
432export function buildGeminiLiveSetupMessage(
433 language?: string,
434 voiceName?: string,
435 systemInstruction?: string,
436 options?: { affectiveDialog?: boolean }
437): { setup: Record<string, unknown> } {
438 const liveConfig = buildGeminiLiveConfig(language, voiceName, systemInstruction)
439 const resolvedVoice = resolveGeminiLiveVoice(voiceName)
440 return {
441 setup: {
442 model: `models/${liveConfig.model}`,
443 generationConfig: {
444 responseModalities: ['AUDIO'],
445 ...(options?.affectiveDialog ? { enableAffectiveDialog: true } : {}),
446 speechConfig: {
447 voiceConfig: {
448 prebuiltVoiceConfig: { voiceName: resolvedVoice }
449 }
450 }
451 },
452 systemInstruction: {
453 parts: [{ text: liveConfig.systemInstruction }]
454 },
455 tools: liveConfig.tools.map((t) => ({
456 functionDeclarations: t.functionDeclarations.map((fd) => ({
457 name: fd.name,
458 description: fd.description,
459 parameters: fd.parameters
460 }))
461 }))
462 }
463 }
464}

Callers 3

openFunction · 0.90
startSessionMethod · 0.90

Calls 2

resolveGeminiLiveVoiceFunction · 0.90
buildGeminiLiveConfigFunction · 0.85

Tested by

no test coverage detected