This commit is contained in:
LanQian 2024-05-22 14:48:04 +08:00
parent f6565ac817
commit fba399b2b5
2 changed files with 6 additions and 0 deletions

View File

@ -38,6 +38,10 @@ async def to_send_conversation(request_data, access_token):
except HTTPException as e:
await chat_service.close_client()
raise HTTPException(status_code=e.status_code, detail=e.detail)
except Exception as e:
await chat_service.close_client()
logger.error(f"Server error, {str(e)}")
raise HTTPException(status_code=500, detail="Server error")
@app.post(f"/{api_prefix}/v1/chat/completions" if api_prefix else "/v1/chat/completions")

View File

@ -48,6 +48,8 @@ class ChatService:
self.api_messages = self.data.get("messages", [])
self.prompt_tokens = 0
self.max_tokens = self.data.get("max_tokens", 2147483647)
if not isinstance(self.max_tokens, int):
self.max_tokens = 2147483647
self.chat_headers = None
self.chat_request = None