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

Session configuration not set according to parameters #59

Open
arnaudbreton opened this issue Oct 29, 2024 · 1 comment
Open

Session configuration not set according to parameters #59

arnaudbreton opened this issue Oct 29, 2024 · 1 comment

Comments

@arnaudbreton
Copy link

Hi,

I'm facing a weird bug where the following code doesn't lead to the session configuration to being properly sent.

On the browser-side (React Native through Expo):

  client.updateSession({
    turn_detection: { type: 'server_vad', threshold: 0.5 },
    input_audio_transcription: { model: 'whisper-1' },
  });

await client.connect();

On the relay server:

clientWs.on('message', (data: any) => {
        const event = JSON.parse(data);
        console.debug(JSON.stringify(event, null, 2));
        console.log(`Relaying "${event.type}" to OpenAI`);
        openAIWs.realtime.send(event.type, event);
}

Most of the time I get the following logs:

Relaying "session.created" to Client
Relaying "session.updated" to Client

In rare occasions, or if I set a breakdown in the updateSession method, I get the following log:

Relaying "session.update" to OpenAI
æ
  "event_id": "evt_ZEcRWpyaoMgCY4amY",
  "type": "session.update",
  "session": æ
    "modalities": Æ
      "text",
      "audio"
    Å,
    "instructions": "",
    "voice": "alloy",
    "input_audio_format": "pcm16",
    "output_audio_format": "pcm16",
    "input_audio_transcription": æ
      "model": "whisper-1"
    å,
    "turn_detection": æ
      "type": "server_vad",
      "threshold": 0.5
    å,
    "tools": ÆÅ,
    "tool_choice": "auto",
    "temperature": 0.8,
    "max_response_output_tokens": 4096
  å
å

This prevents server_vad to be effective as the session configuration isn't sent.

Thanks for your help

@arnaudbreton
Copy link
Author

As a temporary fix, I'm sending the session configuration directly and once the app has received the session.created event.

switch (event?.type) {
            case 'session.created':
                openAIWs.realtime.send('session.update', config);
                break;
}

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