refac
This commit is contained in:
@@ -1836,7 +1836,7 @@ async def chat_completion(
|
|||||||
except HTTPException:
|
except HTTPException:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.debug(f'Error processing chat metadata: {e}')
|
log.warning(f'Error processing chat metadata: {e}')
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
detail=str(e),
|
detail=str(e),
|
||||||
@@ -1908,6 +1908,15 @@ async def chat_completion(
|
|||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
# No chat_id/message_id → legacy/direct API path with no
|
||||||
|
# WebSocket error channel. We must surface the error as
|
||||||
|
# a proper HTTP response; without this the function would
|
||||||
|
# return None which FastAPI serializes as null. #23924
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
|
detail=error_detail,
|
||||||
|
)
|
||||||
finally:
|
finally:
|
||||||
# MCP cleanup — MUST run in the SAME asyncio task as
|
# MCP cleanup — MUST run in the SAME asyncio task as
|
||||||
# connect() because the MCP SDK's streamablehttp_client
|
# connect() because the MCP SDK's streamablehttp_client
|
||||||
|
|||||||
Reference in New Issue
Block a user