Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions fastchat/serve/api_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ def openai_api_stream_iter(
max_tokens=max_new_tokens,
stream=False,
)
if not res.choices or res.choices[0].message is None:
return
text = res.choices[0].message.content
pos = 0
while pos < len(text):
Expand Down
4 changes: 4 additions & 0 deletions fastchat/serve/monitor/classify/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def chat_completion_openai(model, messages, temperature, max_tokens, api_dict=No
max_tokens=max_tokens,
# extra_body={"guided_choice": GUIDED_CHOICES} if GUIDED_CHOICES else None,
)
if not completion.choices or completion.choices[0].message is None:
break
output = completion.choices[0].message.content
# print(output)
break
Expand Down Expand Up @@ -114,6 +116,8 @@ def chat_completion_anthropic(model, messages, temperature, max_tokens, api_dict
temperature=temperature,
system=sys_msg,
)
if not response.content:
break
output = response.content[0].text
break
except anthropic.APIError as e:
Expand Down
2 changes: 2 additions & 0 deletions fastchat/serve/monitor/criteria_labeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def chat_completion_openai(model, messages, temperature, max_tokens, api_dict=No
max_tokens=max_tokens,
# extra_body={"guided_choice": GUIDED_CHOICES} if GUIDED_CHOICES else None,
)
if not completion.choices or completion.choices[0].message is None:
break
output = completion.choices[0].message.content
break
except openai.RateLimitError as e:
Expand Down
Loading