Making tool_calls a vector.

This commit is contained in:
Nicolas Patry 2025-03-05 15:13:25 +01:00
parent 8e92942a18
commit b22eace4b3
No known key found for this signature in database
GPG Key ID: 4242CEF24CB6DBF9
2 changed files with 48 additions and 40 deletions

View File

@ -269,17 +269,25 @@ class ResponseComparator(JSONSnapshotExtension):
def eq_chat_complete_chunk( def eq_chat_complete_chunk(
response: ChatCompletionChunk, other: ChatCompletionChunk response: ChatCompletionChunk, other: ChatCompletionChunk
) -> bool: ) -> bool:
if response.choices[0].delta.content is not None: if response.choices:
return ( if response.choices[0].delta.content is not None:
response.choices[0].delta.content == other.choices[0].delta.content return (
) response.choices[0].delta.content
elif response.choices[0].delta.tool_calls is not None: == other.choices[0].delta.content
return ( )
response.choices[0].delta.tool_calls elif response.choices[0].delta.tool_calls is not None:
== other.choices[0].delta.tool_calls 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: 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: def eq_response(response: Response, other: Response) -> bool:
return response.generated_text == other.generated_text and eq_details( return response.generated_text == other.generated_text and eq_details(

View File

@ -24,7 +24,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -57,7 +57,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -90,7 +90,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -123,7 +123,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -156,7 +156,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -189,7 +189,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -222,7 +222,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -255,7 +255,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -288,7 +288,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -321,7 +321,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -354,7 +354,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -387,7 +387,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -420,7 +420,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -453,7 +453,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -486,7 +486,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -519,7 +519,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -552,7 +552,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -585,7 +585,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -618,7 +618,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -651,7 +651,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -684,7 +684,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -717,7 +717,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -750,7 +750,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -783,7 +783,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195536, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -816,7 +816,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195537, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -849,7 +849,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195537, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -882,7 +882,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195537, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -915,7 +915,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195537, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -948,7 +948,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195537, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",
@ -981,7 +981,7 @@
"logprobs": null "logprobs": null
} }
], ],
"created": 1741195537, "created": 1741211702,
"id": "", "id": "",
"model": "meta-llama/Llama-3.1-8B-Instruct", "model": "meta-llama/Llama-3.1-8B-Instruct",
"object": "chat.completion.chunk", "object": "chat.completion.chunk",