Skip to content

Commit

Permalink
Update anthropic tools example
Browse files Browse the repository at this point in the history
  • Loading branch information
kxtran committed May 21, 2024
1 parent 4b873af commit c74f08f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions examples/logging/anthropic_tools_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,26 @@
client = anthropic.Anthropic()

with client.beta.tools.messages.stream(
model="claude-instant-1.2",
messages=[
model="claude-3-haiku-20240307",
tools=[
{
"role": "user",
"content": "Howdy",
"name": "get_weather",
"description": "Get the weather at a specific location",
"input_schema": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "Unit for the output",
},
},
"required": ["location"],
},
}
],
messages=[{"role": "user", "content": "What is the weather in SF?"}],
max_tokens=1024,
) as stream:
for message in stream:
Expand Down

0 comments on commit c74f08f

Please sign in to comment.