mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-11 03:38:02 +00:00
fix: show the speech engine's reason when it refuses a transcription (#32186)
When an OpenAI-compatible speech-to-text engine or Deepgram rejected a recording, the error shown after dictating only gave the HTTP status, such as "429 Too Many Requests", and the engine's own reason, such as "Quota exceeded" or "Invalid credentials.", was lost. The error now shows that reason. When the engine sends no reason, the HTTP status is shown as before. Fixes #32009
This commit is contained in:
parent
8fa22d0997
commit
6faf540310
1 changed files with 8 additions and 1 deletions
|
|
@ -941,6 +941,8 @@ async def _transcribe_openai(request, file_path, filename, languages, file_dir,
|
|||
if r.status == 200:
|
||||
break
|
||||
|
||||
# raise_for_status releases the response, so read the error body first
|
||||
await r.read()
|
||||
r.raise_for_status()
|
||||
data = await r.json()
|
||||
|
||||
|
|
@ -955,6 +957,8 @@ async def _transcribe_openai(request, file_path, filename, languages, file_dir,
|
|||
res = await r.json()
|
||||
if 'error' in res:
|
||||
detail = f'External: {res["error"].get("message", "")}'
|
||||
else:
|
||||
detail = f'External: {e}'
|
||||
except Exception:
|
||||
detail = f'External: {e}'
|
||||
# LICENSE covers this Open WebUI error identifier.
|
||||
|
|
@ -993,6 +997,7 @@ async def _transcribe_deepgram(request, file_path, languages, file_dir, id):
|
|||
if r.status == 200:
|
||||
break
|
||||
|
||||
await r.read()
|
||||
r.raise_for_status()
|
||||
body = await r.json()
|
||||
|
||||
|
|
@ -1021,9 +1026,11 @@ async def _transcribe_deepgram(request, file_path, languages, file_dir, id):
|
|||
res.get('error', {}).get('message', '')
|
||||
if isinstance(res.get('error'), dict)
|
||||
else str(res.get('error', ''))
|
||||
)
|
||||
) or res.get('err_msg', '')
|
||||
if msg:
|
||||
detail = f'External: {msg}'
|
||||
else:
|
||||
detail = f'External: {e}'
|
||||
except Exception:
|
||||
detail = f'External: {e}'
|
||||
raise Exception(detail)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue