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,9 +269,11 @@ class ResponseComparator(JSONSnapshotExtension):
def eq_chat_complete_chunk(
response: ChatCompletionChunk, other: ChatCompletionChunk
) -> bool:
if response.choices:
if response.choices[0].delta.content is not None:
return (
response.choices[0].delta.content == other.choices[0].delta.content
response.choices[0].delta.content
== other.choices[0].delta.content
)
elif response.choices[0].delta.tool_calls is not None:
return (
@ -279,7 +281,13 @@ class ResponseComparator(JSONSnapshotExtension):
== other.choices[0].delta.tool_calls
)
else:
raise RuntimeError(f"Invalid empty chat chunk {response} vs {other}")
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 {response} vs {other}")
def eq_response(response: Response, other: Response) -> bool:
return response.generated_text == other.generated_text and eq_details(

View File

@ -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",