Skip to content

Commit

Permalink
Add Timeout to HTTPX Client
Browse files Browse the repository at this point in the history
Implemented a timeout for the HTTPX client to avoid ReadTimeout errors. This change ensures the client operations do not hang indefinitely when there are network issues, by providing a predefined time limit for the request to either succeed or raise a timeout exception.
  • Loading branch information
JamesFlare1212 committed Jun 13, 2023
1 parent eab0b92 commit dad538c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion claude_to_chatgpt/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def chat(self, request: Request):
claude_params = self.openai_to_claude_params(openai_params)
api_key = self.get_api_key(headers)

async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(timeout=120.0) as client:
if not claude_params.get("stream", False):
response = await client.post(
f"{self.claude_base_url}/v1/complete",
Expand Down

0 comments on commit dad538c

Please sign in to comment.