Skip to content

Commit

Permalink
fix timeout issue (see: openai/openai-python#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzh1996 committed Apr 27, 2023
1 parent 155764e commit a550b35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM python:3.11
RUN pip install python-telegram-bot==20.2 openai==0.27.2
RUN pip install python-telegram-bot==20.2 git+https://github.com/zzh1996/openai-python.git@fix
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def completion(chat_history, model, chat_id, msg_id): # chat_history = [us
messages.append({"role": roles[role_id], "content": msg})
role_id = 1 - role_id
logging.info('Request (chat_id=%r, msg_id=%r): %s', chat_id, msg_id, messages)
stream = await openai.ChatCompletion.acreate(model=model, messages=messages, stream=True)
stream = await openai.ChatCompletion.acreate(model=model, messages=messages, stream=True, request_timeout=15)
async for response in stream:
logging.info('Response (chat_id=%r, msg_id=%r): %s', chat_id, msg_id, json.dumps(response, ensure_ascii=False))
obj = response['choices'][0]
Expand Down

0 comments on commit a550b35

Please sign in to comment.