diff --git a/log10/_httpx_utils.py b/log10/_httpx_utils.py index 01770fd5..6ca5985b 100644 --- a/log10/_httpx_utils.py +++ b/log10/_httpx_utils.py @@ -379,9 +379,11 @@ def parse_openai_responses(self, responses: list[str]): finish_reason = r_json["choices"][0]["finish_reason"] r_json["object"] = "chat.completion" - r_json["choices"].append(last_message_choices) - if finish_reason: + if last_message_choices: + r_json["choices"].append(last_message_choices) + + if finish_reason and r_json["choices"]: r_json["choices"][0]["finish_reason"] = finish_reason return r_json