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

Text-only mode gives only empty responses #32

Open
andreysamode opened this issue Feb 26, 2025 · 1 comment
Open

Text-only mode gives only empty responses #32

andreysamode opened this issue Feb 26, 2025 · 1 comment

Comments

@andreysamode
Copy link

andreysamode commented Feb 26, 2025

To reproduce:

git clone https://github.com/openai/openai-realtime-agents
cd openai-realtime-agents
rm -rf .next
rm -rf .node_modules
npm i
(add key to .env)
(in App.tsx, change "modalities: ["text", "audio"]," to "modalities: ["text"],"
next dev

Result:

The responses I get from the server are empty - just the timestamp:
Image

Works fine with audio added to in modalities, both in text and audio.

Is there some extra bit of configuration that I need to do to make it work in a text-only mode?

@andreysamode andreysamode changed the title Text-only mode received empty responses Text-only mode gives only empty responses Feb 26, 2025
@andreysamode
Copy link
Author

To solve this, in src/app/hooks/useHandleServerEvent.ts, I changed:

    case "response.output_item.done": {
      const itemId = serverEvent.item?.id;
      if (itemId) {
        updateTranscriptItemStatus(itemId, "DONE");
      }
      break;
    }

to

    case "response.output_item.done": {
      const itemId = serverEvent.item?.id;
      if (itemId) {
        updateTranscriptItemStatus(itemId, "DONE");
        if (serverEvent.item?.content?.[0]?.type === "text") {
          const itemText = serverEvent.item?.content?.[0]?.text || "";
          updateTranscriptMessage(itemId, itemText, false);
        }
      }
      break;
    }

Not sure if it's the best way to do this, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant