Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: text-only mode returning empty responses #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 20 additions & 10 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,28 @@ function App() {
const instructions = currentAgent?.instructions || "";
const tools = currentAgent?.tools || [];

const sessionUpdateEvent = {
type: "session.update",
session: {
modalities: ["text", "audio"],
instructions,

const sessionConfig = {
modalities: ["text"],
input_audio_format: "pcm16",
input_audio_transcription: { model: "whisper-1" },
instructions,
tools,
turn_detection: turnDetection,
};


if (isAudioPlaybackEnabled) {
sessionConfig.modalities.push("audio"); // Changing this to "text" will disable audio
Object.assign(sessionConfig, {
voice: "coral",
input_audio_format: "pcm16",
output_audio_format: "pcm16",
input_audio_transcription: { model: "whisper-1" },
turn_detection: turnDetection,
tools,
},
});
}

const sessionUpdateEvent = {
type: "session.update",
session: sessionConfig,
};

sendClientEvent(sessionUpdateEvent);
Expand Down
10 changes: 10 additions & 0 deletions src/app/hooks/useHandleServerEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ export function useHandleServerEvent({
break;
}

case "conversation.item.text.delta":
case "response.text.delta": {
const itemId = serverEvent.item_id;
const deltaText = serverEvent.delta || "";
if (itemId) {
updateTranscriptMessage(itemId, deltaText, true);
}
break;
}

case "conversation.item.input_audio_transcription.completed": {
const itemId = serverEvent.item_id;
const finalTranscript =
Expand Down