Azure-Samples / aisearch-openai-rag-audio

A simple example implementation of the VoiceRAG pattern to power interactive voice generative AI experiences using RAG with Azure AI Search and Azure OpenAI's gpt-4o-realtime-preview model.
https://azure.microsoft.com/products/search
MIT License
211 stars 105 forks source link

[Feature Request] Add front-end notification on 429 (Too Many Requests) error #9

Open iMicknl opened 3 weeks ago

iMicknl commented 3 weeks ago

Currently gpt-4o-realtime-preview deployments have a very low rate-limit (RPM). When the application faces a 429 ("Too Many Requests"), it will fail in the background, but this status isn't forwarded to the front-end and thus no error message is shown.

Even for a demo application, this would be a good improvement to add.

Error handling request
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/aisearch-openai-rag-audio/app/backend/rtmt.py", line 208, in _websocket_handler
    await self._forward_messages(ws)
  File "/workspaces/aisearch-openai-rag-audio/app/backend/rtmt.py", line 180, in _forward_messages
    async with session.ws_connect("/openai/realtime", headers=headers, params=params) as target_ws:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.12/site-packages/aiohttp/client.py", line 848, in _ws_connect
    raise WSServerHandshakeError(
aiohttp.client_exceptions.WSServerHandshakeError: 429, message='Invalid response status', url=URL('wss://[resource-name].openai.azure.com/openai/realtime?api-version=2024-10-01-preview&deployment=gpt-4o-realtime-preview')