Skip to content

Commit fa7fd11

Browse files
committed
merge
2 parents 0b43f65 + 2392791 commit fa7fd11

26 files changed

+924
-3223
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<a href="https://pypi.python.org/pypi/pydantic-ai"><img src="https://img.shields.io/pypi/v/pydantic-ai.svg" alt="PyPI"></a>
1616
<a href="https://github.com/pydantic/pydantic-ai"><img src="https://img.shields.io/pypi/pyversions/pydantic-ai.svg" alt="versions"></a>
1717
<a href="https://github.com/pydantic/pydantic-ai/blob/main/LICENSE"><img src="https://img.shields.io/github/license/pydantic/pydantic-ai.svg?v" alt="license"></a>
18+
<a href="https://logfire.pydantic.dev/docs/join-slack/"><img src="https://img.shields.io/badge/Slack-Join%20Slack-4A154B?logo=slack" alt="Join Slack" /></a>
1819
</div>
1920

2021
---

docs/.partials/index-header.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<a href="https://github.com/pydantic/pydantic-ai/blob/main/LICENSE">
2424
<img src="https://img.shields.io/github/license/pydantic/pydantic-ai.svg" alt="license">
2525
</a>
26+
<a href="https://logfire.pydantic.dev/docs/join-slack/">
27+
<img src="https://img.shields.io/badge/Slack-Join%20Slack-4A154B?logo=slack" alt="Join Slack" />
28+
</a>
2629
</p>
2730

2831
<p class="text-emphasis">

pydantic_ai_slim/pydantic_ai/_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ async def ask_agent(
284284
stack.enter_context(live) # entering multiple times is idempotent
285285

286286
async for content in handle_stream.stream_output(debounce_by=None):
287-
live.update(Markdown(content, code_theme=code_theme))
287+
live.update(Markdown(str(content), code_theme=code_theme))
288288

289289
assert agent_run.result is not None
290290
return agent_run.result.all_messages()

pydantic_ai_slim/pydantic_ai/_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,13 @@ def now_utc() -> datetime:
205205
return datetime.now(tz=timezone.utc)
206206

207207

208-
def guard_tool_call_id(t: _messages.ToolCallPart | _messages.ToolReturnPart | _messages.RetryPromptPart) -> str:
208+
def guard_tool_call_id(
209+
t: _messages.ToolCallPart
210+
| _messages.ToolReturnPart
211+
| _messages.RetryPromptPart
212+
| _messages.ServerToolCallPart
213+
| _messages.ServerToolReturnPart,
214+
) -> str:
209215
"""Type guard that either returns the tool call id or generates a new one if it's None."""
210216
return t.tool_call_id or generate_tool_call_id()
211217

pydantic_ai_slim/pydantic_ai/agent.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,9 +1766,13 @@ def to_a2a(
17661766
lifespan=lifespan,
17671767
)
17681768

1769-
async def to_cli(self: Self, deps: AgentDepsT = None) -> None:
1769+
async def to_cli(self: Self, deps: AgentDepsT = None, prog_name: str = 'pydantic-ai') -> None:
17701770
"""Run the agent in a CLI chat interface.
17711771
1772+
Args:
1773+
deps: The dependencies to pass to the agent.
1774+
prog_name: The name of the program to use for the CLI. Defaults to 'pydantic-ai'.
1775+
17721776
Example:
17731777
```python {title="agent_to_cli.py" test="skip"}
17741778
from pydantic_ai import Agent
@@ -1783,29 +1787,24 @@ async def main():
17831787

17841788
from pydantic_ai._cli import run_chat
17851789

1786-
# TODO(Marcelo): We need to refactor the CLI code to be able to be able to just pass `agent`, `deps` and
1787-
# `prog_name` from here.
1790+
await run_chat(stream=True, agent=self, deps=deps, console=Console(), code_theme='monokai', prog_name=prog_name)
17881791

1789-
await run_chat(
1790-
stream=True,
1791-
agent=self,
1792-
deps=deps,
1793-
console=Console(),
1794-
code_theme='monokai',
1795-
prog_name='pydantic-ai',
1796-
)
1797-
1798-
def to_cli_sync(self: Self, deps: AgentDepsT = None) -> None:
1792+
def to_cli_sync(self: Self, deps: AgentDepsT = None, prog_name: str = 'pydantic-ai') -> None:
17991793
"""Run the agent in a CLI chat interface with the non-async interface.
18001794
1795+
Args:
1796+
deps: The dependencies to pass to the agent.
1797+
prog_name: The name of the program to use for the CLI. Defaults to 'pydantic-ai'.
1798+
18011799
```python {title="agent_to_cli_sync.py" test="skip"}
18021800
from pydantic_ai import Agent
18031801
18041802
agent = Agent('openai:gpt-4o', instructions='You always respond in Italian.')
18051803
agent.to_cli_sync()
1804+
agent.to_cli_sync(prog_name='assistant')
18061805
```
18071806
"""
1808-
return get_event_loop().run_until_complete(self.to_cli(deps=deps))
1807+
return get_event_loop().run_until_complete(self.to_cli(deps=deps, prog_name=prog_name))
18091808

18101809

18111810
@dataclasses.dataclass(repr=False)

pydantic_ai_slim/pydantic_ai/models/__init__.py

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,25 @@
2828
KnownModelName = TypeAliasType(
2929
'KnownModelName',
3030
Literal[
31-
'anthropic:claude-3-7-sonnet-latest',
31+
'anthropic:claude-2.0',
32+
'anthropic:claude-2.1',
33+
'anthropic:claude-3-5-haiku-20241022',
3234
'anthropic:claude-3-5-haiku-latest',
35+
'anthropic:claude-3-5-sonnet-20240620',
36+
'anthropic:claude-3-5-sonnet-20241022',
3337
'anthropic:claude-3-5-sonnet-latest',
38+
'anthropic:claude-3-7-sonnet-20250219',
39+
'anthropic:claude-3-7-sonnet-latest',
40+
'anthropic:claude-3-haiku-20240307',
41+
'anthropic:claude-3-opus-20240229',
3442
'anthropic:claude-3-opus-latest',
35-
'claude-3-7-sonnet-latest',
36-
'claude-3-5-haiku-latest',
43+
'anthropic:claude-3-sonnet-20240229',
44+
'anthropic:claude-4-opus-20250514',
45+
'anthropic:claude-4-sonnet-20250514',
46+
'anthropic:claude-opus-4-0',
47+
'anthropic:claude-opus-4-20250514',
48+
'anthropic:claude-sonnet-4-0',
49+
'anthropic:claude-sonnet-4-20250514',
3750
'bedrock:amazon.titan-tg1-large',
3851
'bedrock:amazon.titan-text-lite-v1',
3952
'bedrock:amazon.titan-text-express-v1',
@@ -77,8 +90,25 @@
7790
'bedrock:mistral.mixtral-8x7b-instruct-v0:1',
7891
'bedrock:mistral.mistral-large-2402-v1:0',
7992
'bedrock:mistral.mistral-large-2407-v1:0',
93+
'claude-2.0',
94+
'claude-2.1',
95+
'claude-3-5-haiku-20241022',
96+
'claude-3-5-haiku-latest',
97+
'claude-3-5-sonnet-20240620',
98+
'claude-3-5-sonnet-20241022',
8099
'claude-3-5-sonnet-latest',
100+
'claude-3-7-sonnet-20250219',
101+
'claude-3-7-sonnet-latest',
102+
'claude-3-haiku-20240307',
103+
'claude-3-opus-20240229',
81104
'claude-3-opus-latest',
105+
'claude-3-sonnet-20240229',
106+
'claude-4-opus-20250514',
107+
'claude-4-sonnet-20250514',
108+
'claude-opus-4-0',
109+
'claude-opus-4-20250514',
110+
'claude-sonnet-4-0',
111+
'claude-sonnet-4-20250514',
82112
'cohere:c4ai-aya-expanse-32b',
83113
'cohere:c4ai-aya-expanse-8b',
84114
'cohere:command',
@@ -94,32 +124,26 @@
94124
'cohere:command-r7b-12-2024',
95125
'deepseek:deepseek-chat',
96126
'deepseek:deepseek-reasoner',
97-
'google-gla:gemini-1.0-pro',
98127
'google-gla:gemini-1.5-flash',
99128
'google-gla:gemini-1.5-flash-8b',
100129
'google-gla:gemini-1.5-pro',
101-
'google-gla:gemini-2.0-flash-exp',
102-
'google-gla:gemini-2.0-flash-thinking-exp-01-21',
103-
'google-gla:gemini-exp-1206',
130+
'google-gla:gemini-1.0-pro',
104131
'google-gla:gemini-2.0-flash',
105132
'google-gla:gemini-2.0-flash-lite-preview-02-05',
106133
'google-gla:gemini-2.0-pro-exp-02-05',
107-
'google-gla:gemini-2.5-flash-preview-04-17',
134+
'google-gla:gemini-2.5-flash-preview-05-20',
108135
'google-gla:gemini-2.5-pro-exp-03-25',
109-
'google-gla:gemini-2.5-pro-preview-03-25',
110-
'google-vertex:gemini-1.0-pro',
136+
'google-gla:gemini-2.5-pro-preview-05-06',
111137
'google-vertex:gemini-1.5-flash',
112138
'google-vertex:gemini-1.5-flash-8b',
113139
'google-vertex:gemini-1.5-pro',
114-
'google-vertex:gemini-2.0-flash-exp',
115-
'google-vertex:gemini-2.0-flash-thinking-exp-01-21',
116-
'google-vertex:gemini-exp-1206',
140+
'google-vertex:gemini-1.0-pro',
117141
'google-vertex:gemini-2.0-flash',
118142
'google-vertex:gemini-2.0-flash-lite-preview-02-05',
119143
'google-vertex:gemini-2.0-pro-exp-02-05',
120-
'google-vertex:gemini-2.5-flash-preview-04-17',
144+
'google-vertex:gemini-2.5-flash-preview-05-20',
121145
'google-vertex:gemini-2.5-pro-exp-03-25',
122-
'google-vertex:gemini-2.5-pro-preview-03-25',
146+
'google-vertex:gemini-2.5-pro-preview-05-06',
123147
'gpt-3.5-turbo',
124148
'gpt-3.5-turbo-0125',
125149
'gpt-3.5-turbo-0301',

0 commit comments

Comments
 (0)