Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused content None from openai messages #402

Merged
merged 2 commits into from
Jan 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/magentic/chat_model/openai_chat_model.py
Original file line number Diff line number Diff line change
@@ -133,7 +133,6 @@ def _(message: AssistantMessage[Any]) -> ChatCompletionMessageParam:
function_schema = FunctionCallFunctionSchema(message.content.function)
return {
"role": OpenaiMessageRole.ASSISTANT.value,
"content": None,
"tool_calls": [
{
"id": message.content._unique_id,
@@ -149,7 +148,6 @@ def _(message: AssistantMessage[Any]) -> ChatCompletionMessageParam:
if isinstance(message.content, ParallelFunctionCall):
return {
"role": OpenaiMessageRole.ASSISTANT.value,
"content": None,
"tool_calls": [
{
"id": function_call._unique_id,
@@ -194,7 +192,6 @@ def _(message: AssistantMessage[Any]) -> ChatCompletionMessageParam:
function_schema = function_schema_for_type(type(message.content))
return {
"role": OpenaiMessageRole.ASSISTANT.value,
"content": None,
"tool_calls": [
{
# Can be random because no result will be inserted back into the chat
67 changes: 33 additions & 34 deletions tests/cassettes/test_chatprompt/test_chatprompt_readme_example.yaml
Original file line number Diff line number Diff line change
@@ -2,17 +2,16 @@ interactions:
- request:
body: '{"messages": [{"role": "system", "content": "You are a movie buff."}, {"role":
"user", "content": "What is your favorite quote from Harry Potter?"}, {"role":
"assistant", "content": null, "tool_calls": [{"id": "000000000", "type": "function",
"function": {"name": "return_quote", "arguments": "{\"quote\":\"It does not
do to dwell on dreams and forget to live.\",\"character\":\"Albus Dumbledore\"}"}}]},
{"role": "tool", "tool_call_id": "000000000", "content": "null"}, {"role": "user",
"content": "What is your favorite quote from Iron Man?"}], "model": "gpt-4o",
"parallel_tool_calls": false, "stream": true, "stream_options": {"include_usage":
true}, "tool_choice": {"type": "function", "function": {"name": "return_quote"}},
"tools": [{"type": "function", "function": {"name": "return_quote", "parameters":
{"properties": {"quote": {"title": "Quote", "type": "string"}, "character":
{"title": "Character", "type": "string"}}, "required": ["quote", "character"],
"type": "object"}}}]}'
"assistant", "tool_calls": [{"id": "000000000", "type": "function", "function":
{"name": "return_quote", "arguments": "{\"quote\":\"It does not do to dwell
on dreams and forget to live.\",\"character\":\"Albus Dumbledore\"}"}}]}, {"role":
"tool", "tool_call_id": "000000000", "content": "null"}, {"role": "user", "content":
"What is your favorite quote from Iron Man?"}], "model": "gpt-4o", "parallel_tool_calls":
false, "stream": true, "stream_options": {"include_usage": true}, "tool_choice":
{"type": "function", "function": {"name": "return_quote"}}, "tools": [{"type":
"function", "function": {"name": "return_quote", "parameters": {"properties":
{"quote": {"title": "Quote", "type": "string"}, "character": {"title": "Character",
"type": "string"}}, "required": ["quote", "character"], "type": "object"}}}]}'
headers:
accept:
- application/json
@@ -21,13 +20,13 @@ interactions:
connection:
- keep-alive
content-length:
- '988'
- '971'
content-type:
- application/json
host:
- api.openai.com
user-agent:
- OpenAI/Python 1.54.4
- OpenAI/Python 1.59.3
x-stainless-arch:
- arm64
x-stainless-async:
@@ -37,7 +36,7 @@ interactions:
x-stainless-os:
- MacOS
x-stainless-package-version:
- 1.54.4
- 1.59.3
x-stainless-retry-count:
- '0'
x-stainless-runtime:
@@ -48,56 +47,56 @@ interactions:
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: 'data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_ClHm8dDnFk3Wtq2v0kk5vZvK","type":"function","function":{"name":"return_quote","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null}
string: 'data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_DWCoPgZ6a1kfCtlW5ftA8C4D","type":"function","function":{"name":"return_quote","arguments":""}}],"refusal":null},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\""}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"quote"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"quote"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"I"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"I"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
am"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
Iron"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
Man"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":".\",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":".\",\""}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"character"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"character"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":\""}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Tony"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"Tony"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"
Stark"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null}
data: {"id":"chatcmpl-AWvDHV0YBg92gya2uKkeGWxPbIS4N","object":"chat.completion.chunk","created":1732409787,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[],"usage":{"prompt_tokens":125,"completion_tokens":13,"total_tokens":138,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}
data: {"id":"chatcmpl-AokerhRojPD1bKjnMDI89GBsH4eyu","object":"chat.completion.chunk","created":1736659117,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[],"usage":{"prompt_tokens":125,"completion_tokens":13,"total_tokens":138,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}
data: [DONE]
@@ -108,13 +107,13 @@ interactions:
CF-Cache-Status:
- DYNAMIC
CF-RAY:
- 8e7570710c5c17e2-SJC
- 900aafdbe9aa2f2e-LAX
Connection:
- keep-alive
Content-Type:
- text/event-stream; charset=utf-8
Date:
- Sun, 24 Nov 2024 00:56:27 GMT
- Sun, 12 Jan 2025 05:18:37 GMT
Server:
- cloudflare
Transfer-Encoding:
@@ -126,7 +125,7 @@ interactions:
alt-svc:
- h3=":443"; ma=86400
openai-processing-ms:
- '492'
- '231'
openai-version:
- '2020-10-01'
strict-transport-security:
@@ -144,7 +143,7 @@ interactions:
x-ratelimit-reset-tokens:
- 100ms
x-request-id:
- req_6b2623fe248b7024f7c51d3d1a0f730c
- req_b749276b21ce7d0ceebaf8ea5f351d25
status:
code: 200
message: OK
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
interactions:
- request:
body: '{"messages": [{"role": "user", "content": "Use the plus function to add
1 and 2."}, {"role": "assistant", "content": null, "tool_calls": [{"id": "000000000",
"type": "function", "function": {"name": "plus", "arguments": "{\"a\":1,\"b\":2}"}}]},
1 and 2."}, {"role": "assistant", "tool_calls": [{"id": "000000000", "type":
"function", "function": {"name": "plus", "arguments": "{\"a\":1,\"b\":2}"}}]},
{"role": "tool", "tool_call_id": "000000000", "content": "{\"value\":3}"}],
"model": "gpt-4o", "stream": true, "stream_options": {"include_usage": true}}'
headers:
@@ -13,13 +13,13 @@ interactions:
connection:
- keep-alive
content-length:
- '398'
- '381'
content-type:
- application/json
host:
- api.openai.com
user-agent:
- OpenAI/Python 1.54.4
- OpenAI/Python 1.59.3
x-stainless-arch:
- arm64
x-stainless-async:
@@ -29,7 +29,7 @@ interactions:
x-stainless-os:
- MacOS
x-stainless-package-version:
- 1.54.4
- 1.59.3
x-stainless-retry-count:
- '0'
x-stainless-runtime:
@@ -40,56 +40,56 @@ interactions:
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: 'data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null}
string: 'data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"The"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"The"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"
sum"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"
of"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"
"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"1"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"1"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"
and"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"
"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"2"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"2"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"
is"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"
"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"3"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"3"},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null}
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null}
data: {"id":"chatcmpl-AWvDIRQh9f5YXVT8XzqKgnPFgk3Ix","object":"chat.completion.chunk","created":1732409788,"model":"gpt-4o-2024-08-06","system_fingerprint":"fp_7f6be3efb0","choices":[],"usage":{"prompt_tokens":48,"completion_tokens":12,"total_tokens":60,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}
data: {"id":"chatcmpl-Aokes30cqRn8A69mQoiZ1oprIPtZC","object":"chat.completion.chunk","created":1736659118,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_b7d65f1a5b","choices":[],"usage":{"prompt_tokens":48,"completion_tokens":12,"total_tokens":60,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}
data: [DONE]
@@ -100,13 +100,13 @@ interactions:
CF-Cache-Status:
- DYNAMIC
CF-RAY:
- 8e7570762c13270c-SJC
- 900aafdf888d7cf8-LAX
Connection:
- keep-alive
Content-Type:
- text/event-stream; charset=utf-8
Date:
- Sun, 24 Nov 2024 00:56:28 GMT
- Sun, 12 Jan 2025 05:18:38 GMT
Server:
- cloudflare
Transfer-Encoding:
@@ -118,7 +118,7 @@ interactions:
alt-svc:
- h3=":443"; ma=86400
openai-processing-ms:
- '288'
- '273'
openai-version:
- '2020-10-01'
strict-transport-security:
@@ -130,13 +130,13 @@ interactions:
x-ratelimit-remaining-requests:
- '499'
x-ratelimit-remaining-tokens:
- '29958'
- '29969'
x-ratelimit-reset-requests:
- 120ms
x-ratelimit-reset-tokens:
- 83ms
- 62ms
x-request-id:
- req_abfb62ec782d6511ea24e383bfbc67c5
- req_f72fe263fe5add274a533a615419c020
status:
code: 200
message: OK
101 changes: 43 additions & 58 deletions tests/cassettes/test_prompt_chain/test_async_prompt_chain.yaml

Large diffs are not rendered by default.

85 changes: 42 additions & 43 deletions tests/cassettes/test_prompt_chain/test_prompt_chain.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@ interactions:
- request:
body: '{"messages": [{"role": "system", "content": "You are a movie buff."}, {"role":
"user", "content": "What is your favorite quote from Harry Potter?"}, {"role":
"assistant", "content": null, "tool_calls": [{"id": "000000000", "type": "function",
"function": {"name": "return_quote", "arguments": "{\"quote\":\"It does not
do to dwell on dreams and forget to live.\",\"character\":\"Albus Dumbledore\"}"}}]},
{"role": "tool", "tool_call_id": "000000000", "content": "null"}, {"role": "assistant",
"assistant", "tool_calls": [{"id": "000000000", "type": "function", "function":
{"name": "return_quote", "arguments": "{\"quote\":\"It does not do to dwell
on dreams and forget to live.\",\"character\":\"Albus Dumbledore\"}"}}]}, {"role":
"tool", "tool_call_id": "000000000", "content": "null"}, {"role": "assistant",
"content": "."}, {"role": "user", "content": "What is your favorite quote from
{movie}?"}], "model": "mistral-large-latest", "stream": true, "tool_choice":
"any", "tools": [{"type": "function", "function": {"name": "return_quote", "parameters":
@@ -20,13 +20,13 @@ interactions:
connection:
- keep-alive
content-length:
- '914'
- '897'
content-type:
- application/json
host:
- api.mistral.ai
user-agent:
- OpenAI/Python 1.54.4
- OpenAI/Python 1.59.3
x-stainless-arch:
- arm64
x-stainless-async:
@@ -36,7 +36,7 @@ interactions:
x-stainless-os:
- MacOS
x-stainless-package-version:
- 1.54.4
- 1.59.3
x-stainless-retry-count:
- '0'
x-stainless-runtime:
@@ -47,10 +47,10 @@ interactions:
uri: https://api.mistral.ai/v1/chat/completions
response:
body:
string: 'data: {"id":"b8ffbb14857d4d0fa4833410483e048f","object":"chat.completion.chunk","created":1732409785,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
string: 'data: {"id":"60db5249cccd497a86a6e391d041494f","object":"chat.completion.chunk","created":1736659116,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"b8ffbb14857d4d0fa4833410483e048f","object":"chat.completion.chunk","created":1732409785,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"cIwFIgNyc","function":{"name":"return_quote","arguments":"{\"quote\":
data: {"id":"60db5249cccd497a86a6e391d041494f","object":"chat.completion.chunk","created":1736659116,"model":"mistral-large-latest","choices":[{"index":0,"delta":{"tool_calls":[{"id":"JdDHRctXt","function":{"name":"return_quote","arguments":"{\"quote\":
\"May the Force be with you.\", \"character\": \"Obi-Wan Kenobi\"}"}}]},"finish_reason":"tool_calls"}],"usage":{"prompt_tokens":185,"total_tokens":223,"completion_tokens":38}}
@@ -62,13 +62,13 @@ interactions:
CF-Cache-Status:
- DYNAMIC
CF-RAY:
- 8e757066ba8b175e-SJC
- 900aafcb9a46171e-SJC
Connection:
- keep-alive
Content-Type:
- text/event-stream; charset=utf-8
Date:
- Sun, 24 Nov 2024 00:56:26 GMT
- Sun, 12 Jan 2025 05:18:37 GMT
Server:
- cloudflare
Transfer-Encoding:
@@ -84,23 +84,23 @@ interactions:
ratelimitbysize-remaining:
- '1967969'
ratelimitbysize-reset:
- '35'
- '26'
x-envoy-upstream-service-time:
- '1194'
- '2221'
x-kong-proxy-latency:
- '1'
- '3'
x-kong-request-id:
- 3627e2565677d509dc0d4a4a83ca3175
- 75058115a5adf01609a9bc5a00f2c921
x-kong-upstream-latency:
- '1195'
- '2222'
x-ratelimitbysize-limit-minute:
- '2000000'
x-ratelimitbysize-limit-month:
- '10000000000'
x-ratelimitbysize-remaining-minute:
- '1967969'
x-ratelimitbysize-remaining-month:
- '9998079275'
- '9999967969'
status:
code: 200
message: OK
3 changes: 0 additions & 3 deletions tests/chat_model/test_openai_chat_model.py
Original file line number Diff line number Diff line change
@@ -60,7 +60,6 @@ def plus(a: int, b: int) -> int:
AssistantMessage(42),
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": ANY,
@@ -74,7 +73,6 @@ def plus(a: int, b: int) -> int:
AssistantMessage(FunctionCall(plus, 1, 2)),
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": ANY,
@@ -92,7 +90,6 @@ def plus(a: int, b: int) -> int:
),
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": ANY,