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
6 changes: 6 additions & 0 deletions api/azureai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
def get_first_message_content(completion: ChatCompletion) -> str:
r"""When we only need the content of the first message.
It is the default parser for chat completion."""
if (
not completion.choices
or completion.choices[0].message is None
or completion.choices[0].message.content is None
):
raise ValueError("LLM returned empty or filtered response")
return completion.choices[0].message.content


Expand Down
6 changes: 6 additions & 0 deletions api/openai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ def get_first_message_content(completion: ChatCompletion) -> str:
r"""When we only need the content of the first message.
It is the default parser for chat completion."""
log.debug(f"raw completion: {completion}")
if (
not completion.choices
or completion.choices[0].message is None
or completion.choices[0].message.content is None
):
raise ValueError("LLM returned empty or filtered response")
return completion.choices[0].message.content


Expand Down