Skip to content

Commit

Permalink
docs: use latest sonnet in example snippets (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and RobertCraigie committed Dec 10, 2024
1 parent df1a549 commit 1ad9e4f
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ message = client.messages.create(
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
)
print(message.content)
```
Expand Down Expand Up @@ -70,7 +70,7 @@ async def main() -> None:
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
)
print(message.content)

Expand All @@ -97,7 +97,7 @@ stream = client.messages.create(
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
stream=True,
)
for event in stream:
Expand All @@ -119,7 +119,7 @@ stream = await client.messages.create(
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
stream=True,
)
async for event in stream:
Expand All @@ -145,7 +145,7 @@ async def main() -> None:
"content": "Say hello there!",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
) as stream:
async for text in stream.text_stream:
print(text, end="", flush=True)
Expand Down Expand Up @@ -198,15 +198,15 @@ await client.beta.messages.batches.create(
{
"custom_id": "my-first-request",
"params": {
"model": "claude-3-5-sonnet-20240620",
"model": "claude-3-5-sonnet-latest",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello, world"}],
},
},
{
"custom_id": "my-second-request",
"params": {
"model": "claude-3-5-sonnet-20240620",
"model": "claude-3-5-sonnet-latest",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hi again, friend"}],
},
Expand Down Expand Up @@ -250,7 +250,7 @@ message = client.messages.create(
"content": "Hello!",
}
],
model="anthropic.claude-3-sonnet-20240229-v1:0",
model="anthropic.claude-3-5-sonnet-20241022-v2:0",
)
print(message)
```
Expand Down Expand Up @@ -281,7 +281,7 @@ from anthropic import AnthropicVertex
client = AnthropicVertex()

message = client.messages.create(
model="claude-3-sonnet@20240229",
model="claude-3-5-sonnet-v2@20241022",
max_tokens=100,
messages=[
{
Expand Down Expand Up @@ -399,7 +399,7 @@ try:
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
)
except anthropic.APIConnectionError as e:
print("The server could not be reached")
Expand Down Expand Up @@ -440,7 +440,7 @@ message = client.messages.create(
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
)
print(message._request_id) # req_018EeWyXxfu5pfWkrYcMdjWG
```
Expand Down Expand Up @@ -475,7 +475,7 @@ client.with_options(max_retries=5).messages.create(
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
)
```

Expand Down Expand Up @@ -507,7 +507,7 @@ client.with_options(timeout=5.0).messages.create(
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
)
```

Expand Down Expand Up @@ -571,7 +571,7 @@ response = client.messages.with_raw_response.create(
"role": "user",
"content": "Hello, Claude",
}],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
)
print(response.headers.get('X-My-Header'))

Expand Down Expand Up @@ -605,7 +605,7 @@ with client.messages.with_streaming_response.create(
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
) as response:
print(response.headers.get("X-My-Header"))

Expand Down
2 changes: 1 addition & 1 deletion examples/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
],
},
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
)
print(response.model_dump_json(indent=2))
4 changes: 2 additions & 2 deletions examples/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"content": "Hello!",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
)
print(response)

Expand All @@ -30,6 +30,6 @@
"content": "How are you?",
},
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
)
print(response2)
2 changes: 1 addition & 1 deletion examples/messages_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async def main() -> None:
"content": "Say hello there!",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
) as stream:
async for event in stream:
if event.type == "text":
Expand Down
4 changes: 2 additions & 2 deletions examples/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
]

message = client.messages.create(
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
max_tokens=1024,
messages=[user_message],
tools=tools,
Expand All @@ -32,7 +32,7 @@

tool = next(c for c in message.content if c.type == "tool_use")
response = client.messages.create(
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
max_tokens=1024,
messages=[
user_message,
Expand Down
2 changes: 1 addition & 1 deletion examples/tools_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
async def main() -> None:
async with client.messages.stream(
max_tokens=1024,
model="claude-3-haiku-20240307",
model="claude-3-5-sonnet-latest",
tools=[
{
"name": "get_weather",
Expand Down
4 changes: 2 additions & 2 deletions helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async with client.messages.stream(
"content": "Say hello there!",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
) as stream:
async for text in stream.text_stream:
print(text, end="", flush=True)
Expand Down Expand Up @@ -60,7 +60,7 @@ async with client.messages.stream(
"content": "Say hello there!",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
) as stream:
async for event in stream:
if event.type == "text":
Expand Down
8 changes: 4 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
),
),
cast_to=httpx.Response,
Expand All @@ -772,7 +772,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
),
),
cast_to=httpx.Response,
Expand Down Expand Up @@ -1625,7 +1625,7 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter)
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
),
),
cast_to=httpx.Response,
Expand All @@ -1652,7 +1652,7 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter)
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
model="claude-3-5-sonnet-latest",
),
),
cast_to=httpx.Response,
Expand Down

0 comments on commit 1ad9e4f

Please sign in to comment.