Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/friendly-dragons-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@livekit/agents-plugin-google': patch
---

Fix Google Realtime API missing modalities field on MessageGeneration. This resolves the "Text message received from Realtime API with audio modality" error introduced in version 1.0.18.
8 changes: 7 additions & 1 deletion plugins/google/src/beta/realtime/realtime_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,14 +1176,20 @@ export class RealtimeSession extends llm.RealtimeSession {
};

// Close audio stream if audio output is not supported by the model
if (!this.options.responseModalities.includes(Modality.AUDIO)) {
if (!this._realtimeModel.capabilities.audioOutput) {
this.currentGeneration.audioChannel.close();
}

// Determine modalities based on the model's audio_output capability
const modalities: ('text' | 'audio')[] = this._realtimeModel.capabilities.audioOutput
? ['audio', 'text']
: ['text'];

this.currentGeneration.messageChannel.write({
messageId: responseId,
textStream: this.currentGeneration.textChannel.stream(),
audioStream: this.currentGeneration.audioChannel.stream(),
modalities: Promise.resolve(modalities),
});

const generationEvent: llm.GenerationCreatedEvent = {
Expand Down
Loading