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 · 4 comments
Open

Text-only mode gives only empty responses #32

andreysamode opened this issue Feb 26, 2025 · 4 comments

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.

@paix26875
Copy link

paix26875 commented Mar 2, 2025

I found a way to resolve it. You can fix the problem by replacing:

case "response.audio_transcript.delta":

with:

case "response.text.delta":

in src/app/hooks/useHandleServerEvent.ts.
This should ensure that text-only mode works correctly. Hope this is helpful! 🚀

@AbrahamNobleOX
Copy link

@andreysamode, @paix26875

I provided a better and flexible approach in the PR below. Let me know your thoughts:

Branch: https://github.com/AbrahamNobleOX/openai-realtime-agents/tree/enabling-text-only

PR: #33

@paix26875
Copy link

@AbrahamNobleOX
Thank you for working on this! I really appreciate it. I'll take a look at your PR. 🚀

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

3 participants