From e5a2e6438e6f7455c7f0dcc304cd1b08329afe8b Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 1 Nov 2026 19:33:45 +0900 Subject: [PATCH] refac --- backend/open_webui/routers/audio/realtime.py | 10 +++++++++- src/lib/utils/realtime.ts | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/routers/audio/realtime.py b/backend/open_webui/routers/audio/realtime.py index c9c506eb34..5243cabad5 100644 --- a/backend/open_webui/routers/audio/realtime.py +++ b/backend/open_webui/routers/audio/realtime.py @@ -493,7 +493,15 @@ async def realtime_call(ws: WebSocket): if event == {'type': 'bridge.ping'}: await ws.send_json({'type': 'bridge.pong'}) continue - command = protocol.command(event) + try: + command = protocol.command(event) + except (ValueError, TypeError): + if not isinstance(event, dict) or event.get('type') != 'conversation.item.truncate': + raise + await ws.send_json( + {'type': 'bridge.error', 'message': 'Invalid audio truncation request', 'fatal': False} + ) + continue if event['type'] == 'bridge.result': protocol.requested.add(f'result:{event["call_id"]}') for item in command if isinstance(command, list) else [command]: diff --git a/src/lib/utils/realtime.ts b/src/lib/utils/realtime.ts index 771fef9b11..4f130839ea 100644 --- a/src/lib/utils/realtime.ts +++ b/src/lib/utils/realtime.ts @@ -334,7 +334,8 @@ export class RealtimeCall { private event(event: any) { const type = event.type; if (type === 'bridge.error') { - this.fail(event.message); + if (event.fatal === false) this.options.error(event.message); + else this.fail(event.message); return; } if (type === 'bridge.pong') {