Skip to content

Commit

Permalink
Fix the bug in error handling when the API does not support the conte…
Browse files Browse the repository at this point in the history
…nt field as a list.
  • Loading branch information
yym68686 committed Jul 2, 2024
1 parent b31edae commit 7ca48d9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ModelMerge/models/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,16 @@ def ask_stream(
if "tool_choice" in json_post:
del json_post["tool_choice"]
continue
if response.status_code == 503:
print("response.text", response.text)
if "Sorry, server is busy" in response.text:
for index, mess in enumerate(json_post["messages"]):
if type(mess["content"]) == list:
json_post["messages"][index] = {
"role": mess["role"],
"content": mess["content"][0]["text"]
}
continue
if response.status_code == 200:
break
if response.status_code != 200:
Expand Down

0 comments on commit 7ca48d9

Please sign in to comment.