fix timeout in chat
This commit is contained in:
parent
1afa22ea13
commit
4f82307cd9
1 changed files with 4 additions and 2 deletions
|
|
@ -19,7 +19,8 @@ class ChatService:
|
|||
|
||||
return httpx.AsyncClient(
|
||||
base_url=self.base_url,
|
||||
headers=headers
|
||||
headers=headers,
|
||||
timeout=httpx.Timeout(60.0, connect=10.0) # 30s total timeout, 10s connect timeout
|
||||
)
|
||||
|
||||
async def send_message(self, session_id: str, message: str) -> Dict[str, Any]:
|
||||
|
|
@ -39,6 +40,7 @@ class ChatService:
|
|||
print(response.json())
|
||||
raise Exception(f"Error sending message to talestorm-ai: {response.status_code} {response.json()}")
|
||||
except Exception as e:
|
||||
# raise e
|
||||
return {
|
||||
"chat_session_id": session_id,
|
||||
"message": f"I'm sorry, I'm experiencing technical difficulties. Please try again later. Error: {str(e)}"
|
||||
|
|
@ -120,7 +122,7 @@ class ChatService:
|
|||
}
|
||||
|
||||
except Exception as e:
|
||||
raise e
|
||||
# raise e
|
||||
return {
|
||||
"session_id": session_id or "fallback-session",
|
||||
"answer": f"I'm sorry, I'm experiencing technical difficulties. Please try again later. Error: {str(e)}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue