diff --git a/integration-tests/conftest.py b/integration-tests/conftest.py index 01250ce2..a2142af6 100644 --- a/integration-tests/conftest.py +++ b/integration-tests/conftest.py @@ -269,17 +269,25 @@ class ResponseComparator(JSONSnapshotExtension): def eq_chat_complete_chunk( response: ChatCompletionChunk, other: ChatCompletionChunk ) -> bool: - if response.choices[0].delta.content is not None: - return ( - response.choices[0].delta.content == other.choices[0].delta.content - ) - elif response.choices[0].delta.tool_calls is not None: - return ( - response.choices[0].delta.tool_calls - == other.choices[0].delta.tool_calls - ) + if response.choices: + if response.choices[0].delta.content is not None: + return ( + response.choices[0].delta.content + == other.choices[0].delta.content + ) + elif response.choices[0].delta.tool_calls is not None: + return ( + response.choices[0].delta.tool_calls + == other.choices[0].delta.tool_calls + ) + else: + raise RuntimeError( + f"Invalid empty chat chunk {response} vs {other}" + ) + elif response.usage is not None: + return response.usage == other.usage else: - raise RuntimeError(f"Invalid empty chat chunk {response} vs {other}") + raise RuntimeError(f"Invalid empty chat {response} vs {other}") def eq_response(response: Response, other: Response) -> bool: return response.generated_text == other.generated_text and eq_details( diff --git a/integration-tests/models/__snapshots__/test_tools_llama/test_flash_llama_grammar_tools_openai.json b/integration-tests/models/__snapshots__/test_tools_llama/test_flash_llama_grammar_tools_openai.json index e6d78924..21023738 100644 --- a/integration-tests/models/__snapshots__/test_tools_llama/test_flash_llama_grammar_tools_openai.json +++ b/integration-tests/models/__snapshots__/test_tools_llama/test_flash_llama_grammar_tools_openai.json @@ -24,7 +24,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -57,7 +57,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -90,7 +90,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -123,7 +123,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -156,7 +156,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -189,7 +189,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -222,7 +222,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -255,7 +255,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -288,7 +288,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -321,7 +321,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -354,7 +354,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -387,7 +387,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -420,7 +420,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -453,7 +453,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -486,7 +486,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -519,7 +519,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -552,7 +552,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -585,7 +585,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -618,7 +618,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -651,7 +651,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -684,7 +684,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -717,7 +717,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -750,7 +750,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -783,7 +783,7 @@ "logprobs": null } ], - "created": 1741195536, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -816,7 +816,7 @@ "logprobs": null } ], - "created": 1741195537, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -849,7 +849,7 @@ "logprobs": null } ], - "created": 1741195537, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -882,7 +882,7 @@ "logprobs": null } ], - "created": 1741195537, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -915,7 +915,7 @@ "logprobs": null } ], - "created": 1741195537, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -948,7 +948,7 @@ "logprobs": null } ], - "created": 1741195537, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk", @@ -981,7 +981,7 @@ "logprobs": null } ], - "created": 1741195537, + "created": 1741211702, "id": "", "model": "meta-llama/Llama-3.1-8B-Instruct", "object": "chat.completion.chunk",