@@ -43,6 +43,7 @@ def test_parse_nothing(client: OpenAI, respx_mock: MockRouter, monkeypatch: pyte
43
43
content_snapshot = snapshot (
44
44
'{"id": "chatcmpl-ABfvaueLEMLNYbT8YzpJxsmiQ6HSY", "object": "chat.completion", "created": 1727346142, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "I\' m unable to provide real-time weather updates. To get the current weather in San Francisco, I recommend checking a reliable weather website or app like the Weather Channel or a local news station.", "refusal": null}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 14, "completion_tokens": 37, "total_tokens": 51, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_b40fb1c6fb"}'
45
45
),
46
+ path = "/chat/completions" ,
46
47
mock_client = client ,
47
48
respx_mock = respx_mock ,
48
49
)
@@ -112,6 +113,7 @@ class Location(BaseModel):
112
113
content_snapshot = snapshot (
113
114
'{"id": "chatcmpl-ABfvbtVnTu5DeC4EFnRYj8mtfOM99", "object": "chat.completion", "created": 1727346143, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "{\\ "city\\ ":\\ "San Francisco\\ ",\\ "temperature\\ ":65,\\ "units\\ ":\\ "f\\ "}", "refusal": null}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 79, "completion_tokens": 14, "total_tokens": 93, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_5050236cbd"}'
114
115
),
116
+ path = "/chat/completions" ,
115
117
mock_client = client ,
116
118
respx_mock = respx_mock ,
117
119
)
@@ -182,6 +184,7 @@ class Location(BaseModel):
182
184
content_snapshot = snapshot (
183
185
'{"id": "chatcmpl-ABfvcC8grKYsRkSoMp9CCAhbXAd0b", "object": "chat.completion", "created": 1727346144, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "{\\ "city\\ ":\\ "San Francisco\\ ",\\ "temperature\\ ":65,\\ "units\\ ":\\ "f\\ "}", "refusal": null}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 88, "completion_tokens": 14, "total_tokens": 102, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_b40fb1c6fb"}'
184
186
),
187
+ path = "/chat/completions" ,
185
188
mock_client = client ,
186
189
respx_mock = respx_mock ,
187
190
)
@@ -256,6 +259,7 @@ class ColorDetection(BaseModel):
256
259
content_snapshot = snapshot (
257
260
'{"id": "chatcmpl-ABfvjIatz0zrZu50gRbMtlp0asZpz", "object": "chat.completion", "created": 1727346151, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "{\\ "color\\ ":\\ "red\\ ",\\ "hex_color_code\\ ":\\ "#FF0000\\ "}", "refusal": null}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 109, "completion_tokens": 14, "total_tokens": 123, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_5050236cbd"}'
258
261
),
262
+ path = "/chat/completions" ,
259
263
mock_client = client ,
260
264
respx_mock = respx_mock ,
261
265
)
@@ -305,6 +309,7 @@ class Location(BaseModel):
305
309
content_snapshot = snapshot (
306
310
'{"id": "chatcmpl-ABfvp8qzboW92q8ONDF4DPHlI7ckC", "object": "chat.completion", "created": 1727346157, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "{\\ "city\\ ":\\ "San Francisco\\ ",\\ "temperature\\ ":64,\\ "units\\ ":\\ "f\\ "}", "refusal": null}, "logprobs": null, "finish_reason": "stop"}, {"index": 1, "message": {"role": "assistant", "content": "{\\ "city\\ ":\\ "San Francisco\\ ",\\ "temperature\\ ":65,\\ "units\\ ":\\ "f\\ "}", "refusal": null}, "logprobs": null, "finish_reason": "stop"}, {"index": 2, "message": {"role": "assistant", "content": "{\\ "city\\ ":\\ "San Francisco\\ ",\\ "temperature\\ ":63.0,\\ "units\\ ":\\ "f\\ "}", "refusal": null}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 79, "completion_tokens": 44, "total_tokens": 123, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_b40fb1c6fb"}'
307
311
),
312
+ path = "/chat/completions" ,
308
313
mock_client = client ,
309
314
respx_mock = respx_mock ,
310
315
)
@@ -385,6 +390,7 @@ class CalendarEvent:
385
390
content_snapshot = snapshot (
386
391
'{"id": "chatcmpl-ABfvqhz4uUUWsw8Ohw2Mp9B4sKKV8", "object": "chat.completion", "created": 1727346158, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "{\\ "name\\ ":\\ "Science Fair\\ ",\\ "date\\ ":\\ "Friday\\ ",\\ "participants\\ ":[\\ "Alice\\ ",\\ "Bob\\ "]}", "refusal": null}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 92, "completion_tokens": 17, "total_tokens": 109, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_7568d46099"}'
387
392
),
393
+ path = "/chat/completions" ,
388
394
mock_client = client ,
389
395
respx_mock = respx_mock ,
390
396
)
@@ -449,6 +455,7 @@ def test_pydantic_tool_model_all_types(client: OpenAI, respx_mock: MockRouter, m
449
455
content_snapshot = snapshot (
450
456
'{"id": "chatcmpl-ABfvtNiaTNUF6OymZUnEFc9lPq9p1", "object": "chat.completion", "created": 1727346161, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": null, "tool_calls": [{"id": "call_NKpApJybW1MzOjZO2FzwYw0d", "type": "function", "function": {"name": "Query", "arguments": "{\\ "name\\ ":\\ "May 2022 Fulfilled Orders Not Delivered on Time\\ ",\\ "table_name\\ ":\\ "orders\\ ",\\ "columns\\ ":[\\ "id\\ ",\\ "status\\ ",\\ "expected_delivery_date\\ ",\\ "delivered_at\\ ",\\ "shipped_at\\ ",\\ "ordered_at\\ ",\\ "canceled_at\\ "],\\ "conditions\\ ":[{\\ "column\\ ":\\ "ordered_at\\ ",\\ "operator\\ ":\\ ">=\\ ",\\ "value\\ ":\\ "2022-05-01\\ "},{\\ "column\\ ":\\ "ordered_at\\ ",\\ "operator\\ ":\\ "<=\\ ",\\ "value\\ ":\\ "2022-05-31\\ "},{\\ "column\\ ":\\ "status\\ ",\\ "operator\\ ":\\ "=\\ ",\\ "value\\ ":\\ "fulfilled\\ "},{\\ "column\\ ":\\ "delivered_at\\ ",\\ "operator\\ ":\\ ">\\ ",\\ "value\\ ":{\\ "column_name\\ ":\\ "expected_delivery_date\\ "}}],\\ "order_by\\ ":\\ "asc\\ "}"}}], "refusal": null}, "logprobs": null, "finish_reason": "tool_calls"}], "usage": {"prompt_tokens": 512, "completion_tokens": 132, "total_tokens": 644, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_7568d46099"}'
451
457
),
458
+ path = "/chat/completions" ,
452
459
mock_client = client ,
453
460
respx_mock = respx_mock ,
454
461
)
@@ -534,6 +541,7 @@ class Location(BaseModel):
534
541
content_snapshot = snapshot (
535
542
'{"id": "chatcmpl-ABfvvX7eB1KsfeZj8VcF3z7G7SbaA", "object": "chat.completion", "created": 1727346163, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "{\\ "", "refusal": null}, "logprobs": null, "finish_reason": "length"}], "usage": {"prompt_tokens": 79, "completion_tokens": 1, "total_tokens": 80, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_7568d46099"}'
536
543
),
544
+ path = "/chat/completions" ,
537
545
mock_client = client ,
538
546
respx_mock = respx_mock ,
539
547
)
@@ -560,6 +568,7 @@ class Location(BaseModel):
560
568
content_snapshot = snapshot (
561
569
'{"id": "chatcmpl-ABfvwoKVWPQj2UPlAcAKM7s40GsRx", "object": "chat.completion", "created": 1727346164, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": null, "refusal": "I\' m very sorry, but I can\' t assist with that."}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 79, "completion_tokens": 12, "total_tokens": 91, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_5050236cbd"}'
562
570
),
571
+ path = "/chat/completions" ,
563
572
mock_client = client ,
564
573
respx_mock = respx_mock ,
565
574
)
@@ -610,6 +619,7 @@ class GetWeatherArgs(BaseModel):
610
619
content_snapshot = snapshot (
611
620
'{"id": "chatcmpl-ABfvx6Z4dchiW2nya1N8KMsHFrQRE", "object": "chat.completion", "created": 1727346165, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": null, "tool_calls": [{"id": "call_Y6qJ7ofLgOrBnMD5WbVAeiRV", "type": "function", "function": {"name": "GetWeatherArgs", "arguments": "{\\ "city\\ ":\\ "Edinburgh\\ ",\\ "country\\ ":\\ "UK\\ ",\\ "units\\ ":\\ "c\\ "}"}}], "refusal": null}, "logprobs": null, "finish_reason": "tool_calls"}], "usage": {"prompt_tokens": 76, "completion_tokens": 24, "total_tokens": 100, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_e45dabd248"}'
612
621
),
622
+ path = "/chat/completions" ,
613
623
mock_client = client ,
614
624
respx_mock = respx_mock ,
615
625
)
@@ -683,6 +693,7 @@ class GetStockPrice(BaseModel):
683
693
content_snapshot = snapshot (
684
694
'{"id": "chatcmpl-ABfvyvfNWKcl7Ohqos4UFrmMs1v4C", "object": "chat.completion", "created": 1727346166, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": null, "tool_calls": [{"id": "call_fdNz3vOBKYgOIpMdWotB9MjY", "type": "function", "function": {"name": "GetWeatherArgs", "arguments": "{\\ "city\\ ": \\ "Edinburgh\\ ", \\ "country\\ ": \\ "GB\\ ", \\ "units\\ ": \\ "c\\ "}"}}, {"id": "call_h1DWI1POMJLb0KwIyQHWXD4p", "type": "function", "function": {"name": "get_stock_price", "arguments": "{\\ "ticker\\ ": \\ "AAPL\\ ", \\ "exchange\\ ": \\ "NASDAQ\\ "}"}}], "refusal": null}, "logprobs": null, "finish_reason": "tool_calls"}], "usage": {"prompt_tokens": 149, "completion_tokens": 60, "total_tokens": 209, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_b40fb1c6fb"}'
685
695
),
696
+ path = "/chat/completions" ,
686
697
mock_client = client ,
687
698
respx_mock = respx_mock ,
688
699
)
@@ -765,6 +776,7 @@ def test_parse_strict_tools(client: OpenAI, respx_mock: MockRouter, monkeypatch:
765
776
content_snapshot = snapshot (
766
777
'{"id": "chatcmpl-ABfvzdvCI6RaIkiEFNjqGXCSYnlzf", "object": "chat.completion", "created": 1727346167, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": null, "tool_calls": [{"id": "call_CUdUoJpsWWVdxXntucvnol1M", "type": "function", "function": {"name": "get_weather", "arguments": "{\\ "city\\ ":\\ "San Francisco\\ ",\\ "state\\ ":\\ "CA\\ "}"}}], "refusal": null}, "logprobs": null, "finish_reason": "tool_calls"}], "usage": {"prompt_tokens": 48, "completion_tokens": 19, "total_tokens": 67, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_5050236cbd"}'
767
778
),
779
+ path = "/chat/completions" ,
768
780
mock_client = client ,
769
781
respx_mock = respx_mock ,
770
782
)
@@ -842,6 +854,7 @@ class Location(BaseModel):
842
854
content_snapshot = snapshot (
843
855
'{"id": "chatcmpl-ABrDYCa8W1w66eUxKDO8TQF1m6trT", "object": "chat.completion", "created": 1727389540, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "{\\ "city\\ ":\\ "San Francisco\\ ",\\ "temperature\\ ":58,\\ "units\\ ":\\ "f\\ "}", "refusal": null}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 79, "completion_tokens": 14, "total_tokens": 93, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_5050236cbd"}'
844
856
),
857
+ path = "/chat/completions" ,
845
858
mock_client = client ,
846
859
respx_mock = respx_mock ,
847
860
)
@@ -918,6 +931,7 @@ class Location(BaseModel):
918
931
content_snapshot = snapshot (
919
932
'{"id": "chatcmpl-ABrDQWOiw0PK5JOsxl1D9ooeQgznq", "object": "chat.completion", "created": 1727389532, "model": "gpt-4o-2024-08-06", "choices": [{"index": 0, "message": {"role": "assistant", "content": "{\\ "city\\ ":\\ "San Francisco\\ ",\\ "temperature\\ ":65,\\ "units\\ ":\\ "f\\ "}", "refusal": null}, "logprobs": null, "finish_reason": "stop"}], "usage": {"prompt_tokens": 79, "completion_tokens": 14, "total_tokens": 93, "completion_tokens_details": {"reasoning_tokens": 0}}, "system_fingerprint": "fp_5050236cbd"}'
920
933
),
934
+ path = "/chat/completions" ,
921
935
mock_client = async_client ,
922
936
respx_mock = respx_mock ,
923
937
)
0 commit comments