diff --git a/backend/open_webui/routers/audio.py b/backend/open_webui/routers/audio.py index c63ad3bfe7..a9aa93e08a 100644 --- a/backend/open_webui/routers/audio.py +++ b/backend/open_webui/routers/audio.py @@ -376,9 +376,13 @@ async def speech(request: Request, user=Depends(get_verified_user)): if r is not None: status_code = r.status - res = await r.json() - if "error" in res: - detail = f"External: {res['error'].get('message', '')}" + + try: + res = await r.json() + if "error" in res: + detail = f"External: {res['error']}" + except Exception: + detail = f"External: {e}" raise HTTPException( status_code=status_code, diff --git a/backend/open_webui/routers/tasks.py b/backend/open_webui/routers/tasks.py index 3832c0306b..2dec218d92 100644 --- a/backend/open_webui/routers/tasks.py +++ b/backend/open_webui/routers/tasks.py @@ -695,11 +695,11 @@ async def generate_emoji( "max_completion_tokens": 4, } ), - "chat_id": form_data.get("chat_id", None), "metadata": { **(request.state.metadata if hasattr(request.state, "metadata") else {}), "task": str(TASKS.EMOJI_GENERATION), "task_body": form_data, + "chat_id": form_data.get("chat_id", None), }, }