Skip to content

Commit 9ea51bc

Browse files
authored
Add support for claude sonnet 3-7 (#1034)
1 parent f35655f commit 9ea51bc

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

pydantic_ai_slim/pydantic_ai/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828

2929

3030
KnownModelName = Literal[
31+
'anthropic:claude-3-7-sonnet-latest',
3132
'anthropic:claude-3-5-haiku-latest',
3233
'anthropic:claude-3-5-sonnet-latest',
3334
'anthropic:claude-3-opus-latest',
35+
'claude-3-7-sonnet-latest',
3436
'claude-3-5-haiku-latest',
3537
'claude-3-5-sonnet-latest',
3638
'claude-3-opus-latest',

pydantic_ai_slim/pydantic_ai/models/anthropic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
try:
4343
from anthropic import NOT_GIVEN, APIStatusError, AsyncAnthropic, AsyncStream
4444
from anthropic.types import (
45+
ContentBlock,
4546
ImageBlockParam,
4647
Message as AnthropicMessage,
4748
MessageParam,
@@ -69,6 +70,7 @@
6970
) from _import_error
7071

7172
LatestAnthropicModelNames = Literal[
73+
'claude-3-7-sonnet-latest',
7274
'claude-3-5-haiku-latest',
7375
'claude-3-5-sonnet-latest',
7476
'claude-3-opus-latest',
@@ -423,7 +425,7 @@ class AnthropicStreamedResponse(StreamedResponse):
423425
_timestamp: datetime
424426

425427
async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]:
426-
current_block: TextBlock | ToolUseBlock | None = None
428+
current_block: ContentBlock | None = None
427429
current_json: str = ''
428430

429431
async for event in self._response:

pydantic_ai_slim/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ logfire = ["logfire>=2.3"]
4949
openai = ["openai>=1.65.1"]
5050
cohere = ["cohere>=5.13.11"]
5151
vertexai = ["google-auth>=2.36.0", "requests>=2.32.3"]
52-
anthropic = ["anthropic>=0.40.0"]
52+
anthropic = ["anthropic>=0.49.0"]
5353
groq = ["groq>=0.12.0"]
5454
mistral = ["mistralai>=1.2.5"]
5555
# Tools

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)