-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for StreamedResponse with AnthropicChatModel
- Loading branch information
1 parent
f13a080
commit cda92aa
Showing
4 changed files
with
487 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
222 changes: 222 additions & 0 deletions
222
...est_anthropic_chat_model/test_anthropic_chat_model_acomplete_async_streamed_response.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
interactions: | ||
- request: | ||
body: '{"max_tokens": 1024, "messages": [{"role": "user", "content": [{"type": | ||
"text", "text": "Pick a random city. Then get its weather."}]}], "model": "claude-3-opus-20240229", | ||
"tools": [{"name": "get_weather", "description": "Get the weather for a location.", | ||
"input_schema": {"properties": {"location": {"title": "Location", "type": "string"}}, | ||
"required": ["location"], "type": "object"}}], "stream": true}' | ||
headers: | ||
accept: | ||
- application/json | ||
accept-encoding: | ||
- gzip, deflate | ||
anthropic-version: | ||
- '2023-06-01' | ||
connection: | ||
- keep-alive | ||
content-length: | ||
- '404' | ||
content-type: | ||
- application/json | ||
host: | ||
- api.anthropic.com | ||
user-agent: | ||
- AsyncAnthropic/Python 0.39.0 | ||
x-stainless-arch: | ||
- arm64 | ||
x-stainless-async: | ||
- async:asyncio | ||
x-stainless-lang: | ||
- python | ||
x-stainless-os: | ||
- MacOS | ||
x-stainless-package-version: | ||
- 0.39.0 | ||
x-stainless-retry-count: | ||
- '0' | ||
x-stainless-runtime: | ||
- CPython | ||
x-stainless-runtime-version: | ||
- 3.10.15 | ||
x-stainless-stream-helper: | ||
- messages | ||
method: POST | ||
uri: https://api.anthropic.com/v1/messages | ||
response: | ||
body: | ||
string: 'event: message_start | ||
data: {"type":"message_start","message":{"id":"msg_01SBqSC6Ceb3t3h6pXFNw3Rn","type":"message","role":"assistant","model":"claude-3-opus-20240229","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":610,"output_tokens":3}} } | ||
event: content_block_start | ||
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} } | ||
event: ping | ||
data: {"type": "ping"} | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"<thinking>\nTo | ||
get"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" | ||
the weather for a city, the"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" | ||
get_weather tool is needed. It"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" | ||
requires a location parameter.\nThe user"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" | ||
did not specify a city, but"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" | ||
asked me to pick one at"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" | ||
random. So I can in"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"fer | ||
the location parameter by selecting"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" | ||
a city name myself.\nWith"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" | ||
the location inferred, I have"}} | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" | ||
all the required parameters to call the"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" | ||
get_weather tool.\n</thinking"}} | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":">"} } | ||
event: content_block_stop | ||
data: {"type":"content_block_stop","index":0 } | ||
event: content_block_start | ||
data: {"type":"content_block_start","index":1,"content_block":{"type":"tool_use","id":"toolu_01NeeKpbWNsqw53dKdgnCsYY","name":"get_weather","input":{}} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":""} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"{\""} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"location\""} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":": | ||
\"T"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"okyo"} } | ||
event: content_block_delta | ||
data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":"\"}"} } | ||
event: content_block_stop | ||
data: {"type":"content_block_stop","index":1 } | ||
event: message_delta | ||
data: {"type":"message_delta","delta":{"stop_reason":"tool_use","stop_sequence":null},"usage":{"output_tokens":135} } | ||
event: message_stop | ||
data: {"type":"message_stop" } | ||
' | ||
headers: | ||
CF-Cache-Status: | ||
- DYNAMIC | ||
CF-RAY: | ||
- 8ea9a8d14bd1fa22-SJC | ||
Cache-Control: | ||
- no-cache | ||
Connection: | ||
- keep-alive | ||
Content-Type: | ||
- text/event-stream; charset=utf-8 | ||
Date: | ||
- Sat, 30 Nov 2024 09:02:36 GMT | ||
Server: | ||
- cloudflare | ||
Transfer-Encoding: | ||
- chunked | ||
X-Robots-Tag: | ||
- none | ||
request-id: | ||
- req_01QTs1VmrHugipEzMY2oxHfc | ||
via: | ||
- 1.1 google | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
Oops, something went wrong.