Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a2da46c
adding vercel AI chat
samuelcolvin Sep 16, 2025
0018e11
fix sqlite
samuelcolvin Sep 16, 2025
e39612d
Merge branch 'main' into vercel-ai-chat
DouweM Oct 8, 2025
bdd321d
refactoring
DouweM Oct 8, 2025
f0a03d9
Claude-assisted refactoring to unify AG-UI and Vercel AI adapters and…
DouweM Oct 8, 2025
6cae960
Flesh out Adapter and EventStream
DouweM Oct 9, 2025
2acc1c3
fix typecheck, tests, linter
DouweM Oct 10, 2025
2d7c781
Fix Vercel
DouweM Oct 10, 2025
03862a5
cleanup
DouweM Oct 10, 2025
6f51053
Refactor AG-UI streaming
DouweM Oct 10, 2025
013c43b
Start fixing up Vercel events
DouweM Oct 10, 2025
7d4b187
Improvements
DouweM Oct 14, 2025
eef9832
Merge branch 'main' into vercel-ai-chat
DouweM Oct 14, 2025
365f14f
misc
DouweM Oct 14, 2025
45e757e
Add PartEndEvent
DouweM Oct 14, 2025
47a396b
Properly finish Vercel steps and messages
DouweM Oct 14, 2025
7ba0cc7
Update tests for new PartEndEvent
DouweM Oct 14, 2025
f97d6c8
update snapshots
DouweM Oct 15, 2025
6caa37e
Remove extra item in stream_output iteration
DouweM Oct 15, 2025
a09f6ce
resolve some todos
DouweM Oct 15, 2025
b9019e0
resolve some todos, fix snapshots
DouweM Oct 15, 2025
a5c205b
Deduplicate more stream_output messages
DouweM Oct 15, 2025
ab246e8
update snapshots
DouweM Oct 15, 2025
f02834c
add coverage todos
DouweM Oct 16, 2025
c9dec71
Add warning for scenario in https://github.com/pydantic/pydantic-ai/i…
DouweM Oct 16, 2025
3ffd5ed
Start test UI Adapter and EventStream
DouweM Oct 16, 2025
0bf0c97
Fix Groq thinking out of order
DouweM Oct 16, 2025
42e39e2
coverage
DouweM Oct 16, 2025
0b1dea3
tests
DouweM Oct 16, 2025
4622eb5
tests
DouweM Oct 16, 2025
bd6cbc3
coverage
DouweM Oct 16, 2025
aebf039
Merge branch 'main' into vercel-ai-chat
DouweM Oct 27, 2025
5544992
Set Content-Type header on StreamingResponse
DouweM Oct 27, 2025
2b9b830
fix snapshots
DouweM Oct 27, 2025
5bcc597
Fix 3.10 lint
DouweM Oct 27, 2025
0871ac7
Add UIApp, AGUIApp, VercelAIApp
DouweM Oct 27, 2025
d9feb52
Refactoring
DouweM Oct 27, 2025
5cf8802
Clean up Pydantic AI message building
DouweM Oct 27, 2025
e545e5c
fix lint
DouweM Oct 27, 2025
40f4695
coverage
DouweM Oct 28, 2025
7b50c11
Merge branch 'main' into vercel-ai-chat
DouweM Oct 28, 2025
f8be256
fix lint
DouweM Oct 28, 2025
d834583
Reset chat app example
DouweM Oct 28, 2025
3d628b8
AG-UI docs
DouweM Oct 28, 2025
7b4ad0d
Docs
DouweM Oct 28, 2025
d59fdac
coverage
DouweM Oct 29, 2025
50b13ce
Merge branch 'main' into vercel-ai-chat
DouweM Oct 29, 2025
9dbcee8
Remove UIApp
DouweM Oct 29, 2025
92834a9
Merge branch 'main' into vercel-ai-chat
DouweM Oct 29, 2025
1d56cb2
Docs
DouweM Oct 29, 2025
81be052
fix docs
DouweM Oct 29, 2025
e770176
fix docs links
DouweM Oct 29, 2025
52a0a15
Merge branch 'main' into vercel-ai-chat
DouweM Oct 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env*/
/TODO.md
/postgres-data/
.DS_Store
examples/pydantic_ai_examples/.chat_app_messages.sqlite
.chat_app_messages.sqlite
.cache/
.vscode/
/question_graph_history.json
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Designed to give your IDE or AI coding agent as much context as possible for aut
5. **Powerful Evals**:
Enables you to systematically test and [evaluate](https://ai.pydantic.dev/evals) the performance and accuracy of the agentic systems you build, and monitor the performance over time in Pydantic Logfire.

6. **MCP, A2A, and AG-UI**:
Integrates the [Model Context Protocol](https://ai.pydantic.dev/mcp/client), [Agent2Agent](https://ai.pydantic.dev/a2a), and [AG-UI](https://ai.pydantic.dev/ag-ui) standards to give your agent access to external tools and data, let it interoperate with other agents, and build interactive applications with streaming event-based communication.
6. **MCP, A2A, and UI**:
Integrates the [Model Context Protocol](https://ai.pydantic.dev/mcp/overview), [Agent2Agent](https://ai.pydantic.dev/a2a), and various [UI event stream](https://ai.pydantic.dev/ui/overview) standards to give your agent access to external tools and data, let it interoperate with other agents, and build interactive applications with streaming event-based communication.

7. **Human-in-the-Loop Tool Approval**:
Easily lets you flag that certain tool calls [require approval](https://ai.pydantic.dev/deferred-tools#human-in-the-loop-tool-approval) before they can proceed, possibly depending on tool call arguments, conversation history, or user preferences.
Expand Down
1 change: 1 addition & 0 deletions docs-site/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const redirect_lookup: Record<string, string> = {
'/examples': 'examples/setup/',
'/mcp': '/mcp/overview/',
'/models': '/models/overview/',
'/ag-ui': '/ui/ag-ui/'
}

function redirect(pathname: string): string | null {
Expand Down
3 changes: 3 additions & 0 deletions docs/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ async def main():
FinalResultEvent(tool_name=None, tool_call_id=None),
PartDeltaEvent(index=0, delta=TextPartDelta(content_delta='Mexico is Mexico ')),
PartDeltaEvent(index=0, delta=TextPartDelta(content_delta='City.')),
PartEndEvent(
index=0, part=TextPart(content='The capital of Mexico is Mexico City.')
),
AgentRunResultEvent(
result=AgentRunResult(output='The capital of Mexico is Mexico City.')
),
Expand Down
5 changes: 5 additions & 0 deletions docs/api/ui/ag_ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `pydantic_ai.ui.ag_ui`

::: pydantic_ai.ui.ag_ui

::: pydantic_ai.ui.ag_ui.app
3 changes: 3 additions & 0 deletions docs/api/ui/base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `pydantic_ai.ui`

::: pydantic_ai.ui
7 changes: 7 additions & 0 deletions docs/api/ui/vercel_ai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# `pydantic_ai.ui.vercel_ai`

::: pydantic_ai.ui.vercel_ai

::: pydantic_ai.ui.vercel_ai.request_types

::: pydantic_ai.ui.vercel_ai.response_types
4 changes: 2 additions & 2 deletions docs/examples/ag-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Example of using Pydantic AI agents with the [AG-UI Dojo](https://github.com/ag-ui-protocol/ag-ui/tree/main/typescript-sdk/apps/dojo) example app.

See the [AG-UI docs](../ag-ui.md) for more information about the AG-UI integration.
See the [AG-UI docs](../ui/ag-ui.md) for more information about the AG-UI integration.

Demonstrates:

- [AG-UI](../ag-ui.md)
- [AG-UI](../ui/ag-ui.md)
- [Tools](../tools.md)

## Prerequisites
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Designed to give your IDE or AI coding agent as much context as possible for aut
5. **Powerful Evals**:
Enables you to systematically test and [evaluate](evals.md) the performance and accuracy of the agentic systems you build, and monitor the performance over time in Pydantic Logfire.

6. **MCP, A2A, and AG-UI**:
Integrates the [Model Context Protocol](mcp/client.md), [Agent2Agent](a2a.md), and [AG-UI](ag-ui.md) standards to give your agent access to external tools and data, let it interoperate with other agents, and build interactive applications with streaming event-based communication.
6. **MCP, A2A, and UI**:
Integrates the [Model Context Protocol](mcp/overview.md), [Agent2Agent](a2a.md), and various [UI event stream](ui/overview.md) standards to give your agent access to external tools and data, let it interoperate with other agents, and build interactive applications with streaming event-based communication.

7. **Human-in-the-Loop Tool Approval**:
Easily lets you flag that certain tool calls [require approval](deferred-tools.md#human-in-the-loop-tool-approval) before they can proceed, possibly depending on tool call arguments, conversation history, or user preferences.
Expand Down
55 changes: 27 additions & 28 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,35 @@ pip/uv-add "pydantic-ai-slim[openai]"

`pydantic-ai-slim` has the following optional groups:

* `logfire` — installs [`logfire`](logfire.md) [PyPI ↗](https://pypi.org/project/logfire){:target="_blank"}
* `evals` — installs [`pydantic-evals`](evals.md) [PyPI ↗](https://pypi.org/project/pydantic-evals){:target="_blank"}
* `openai` — installs `openai` [PyPI ↗](https://pypi.org/project/openai){:target="_blank"}
* `vertexai` — installs `google-auth` [PyPI ↗](https://pypi.org/project/google-auth){:target="_blank"} and `requests` [PyPI ↗](https://pypi.org/project/requests){:target="_blank"}
* `google` — installs `google-genai` [PyPI ↗](https://pypi.org/project/google-genai){:target="_blank"}
* `anthropic` — installs `anthropic` [PyPI ↗](https://pypi.org/project/anthropic){:target="_blank"}
* `groq` — installs `groq` [PyPI ↗](https://pypi.org/project/groq){:target="_blank"}
* `mistral` — installs `mistralai` [PyPI ↗](https://pypi.org/project/mistralai){:target="_blank"}
* `cohere` - installs `cohere` [PyPI ↗](https://pypi.org/project/cohere){:target="_blank"}
* `bedrock` - installs `boto3` [PyPI ↗](https://pypi.org/project/boto3){:target="_blank"}
* `huggingface` - installs `huggingface-hub[inference]` [PyPI ↗](https://pypi.org/project/huggingface-hub){:target="_blank"}
* `outlines-transformers` - installs `outlines[transformers]` [PyPI ↗](https://pypi.org/project/outlines){:target="_blank"}
* `outlines-llamacpp` - installs `outlines[llamacpp]` [PyPI ↗](https://pypi.org/project/outlines){:target="_blank"}
* `outlines-mlxlm` - installs `outlines[mlxlm]` [PyPI ↗](https://pypi.org/project/outlines){:target="_blank"}
* `outlines-sglang` - installs `outlines[sglang]` [PyPI ↗](https://pypi.org/project/outlines){:target="_blank"}
* `outlines-vllm-offline` - installs `outlines[vllm-offline]` [PyPI ↗](https://pypi.org/project/outlines){:target="_blank"}
* `duckduckgo` - installs `ddgs` [PyPI ↗](https://pypi.org/project/ddgs){:target="_blank"}
* `tavily` - installs `tavily-python` [PyPI ↗](https://pypi.org/project/tavily-python){:target="_blank"}
* `cli` - installs `rich` [PyPI ↗](https://pypi.org/project/rich){:target="_blank"}, `prompt-toolkit` [PyPI ↗](https://pypi.org/project/prompt-toolkit){:target="_blank"}, and `argcomplete` [PyPI ↗](https://pypi.org/project/argcomplete){:target="_blank"}
* `mcp` - installs `mcp` [PyPI ↗](https://pypi.org/project/mcp){:target="_blank"}
* `fastmcp` - installs `fastmcp` [PyPI ↗](https://pypi.org/project/fastmcp){:target="_blank"}
* `a2a` - installs `fasta2a` [PyPI ↗](https://pypi.org/project/fasta2a){:target="_blank"}
* `ag-ui` - installs `ag-ui-protocol` [PyPI ↗](https://pypi.org/project/ag-ui-protocol){:target="_blank"} and `starlette` [PyPI ↗](https://pypi.org/project/starlette){:target="_blank"}
* `dbos` - installs [`dbos`](durable_execution/dbos.md) [PyPI ↗](https://pypi.org/project/dbos){:target="_blank"}
* `prefect` - installs [`prefect`](durable_execution/prefect.md) [PyPI ↗](https://pypi.org/project/prefect){:target="_blank"}

See the [models](models/overview.md) documentation for information on which optional dependencies are required for each model.
* `logfire` — installs [Pydantic Logfire](logfire.md) dependency `logfire` [PyPI ↗](https://pypi.org/project/logfire){:target="_blank"}
* `evals` — installs [Pydantic Evals](evals.md) dependency `pydantic-evals` [PyPI ↗](https://pypi.org/project/pydantic-evals){:target="_blank"}
* `openai` — installs [OpenAI Model](models/openai.md) dependency `openai` [PyPI ↗](https://pypi.org/project/openai){:target="_blank"}
* `vertexai` — installs `GoogleVertexProvider` dependencies `google-auth` [PyPI ↗](https://pypi.org/project/google-auth){:target="_blank"} and `requests` [PyPI ↗](https://pypi.org/project/requests){:target="_blank"}
* `google` — installs [Google Model](models/google.md) dependency `google-genai` [PyPI ↗](https://pypi.org/project/google-genai){:target="_blank"}
* `anthropic` — installs [Anthropic Model](models/anthropic.md) dependency `anthropic` [PyPI ↗](https://pypi.org/project/anthropic){:target="_blank"}
* `groq` — installs [Groq Model](models/groq.md) dependency `groq` [PyPI ↗](https://pypi.org/project/groq){:target="_blank"}
* `mistral` — installs [Mistral Model](models/mistral.md) dependency `mistralai` [PyPI ↗](https://pypi.org/project/mistralai){:target="_blank"}
* `cohere` - installs [Cohere Model](models/cohere.md) dependency `cohere` [PyPI ↗](https://pypi.org/project/cohere){:target="_blank"}
* `bedrock` - installs [Bedrock Model](models/bedrock.md) dependency `boto3` [PyPI ↗](https://pypi.org/project/boto3){:target="_blank"}
* `huggingface` - installs [Hugging Face Model](models/huggingface.md) dependency `huggingface-hub[inference]` [PyPI ↗](https://pypi.org/project/huggingface-hub){:target="_blank"}
* `outlines-transformers` - installs [Outlines Model](models/outlines.md) dependency `outlines[transformers]` [PyPI ↗](https://pypi.org/project/outlines){:target="_blank"}
* `outlines-llamacpp` - installs [Outlines Model](models/outlines.md) dependency `outlines[llamacpp]` [PyPI ↗](https://pypi.org/project/outlines){:target="_blank"}
* `outlines-mlxlm` - installs [Outlines Model](models/outlines.md) dependency `outlines[mlxlm]` [PyPI ↗](https://pypi.org/project/outlines){:target="_blank"}
* `outlines-sglang` - installs [Outlines Model](models/outlines.md) dependency `outlines[sglang]` [PyPI ↗](https://pypi.org/project/outlines){:target="_blank"}
* `outlines-vllm-offline` - installs [Outlines Model](models/outlines.md) dependencies `outlines` [PyPI ↗](https://pypi.org/project/outlines){:target="_blank"} and `vllm` [PyPI ↗](https://pypi.org/project/vllm){:target="_blank"}
* `duckduckgo` - installs [DuckDuckGo Search Tool](common-tools.md#duckduckgo-search-tool) dependency `ddgs` [PyPI ↗](https://pypi.org/project/ddgs){:target="_blank"}
* `tavily` - installs [Tavily Search Tool](common-tools.md#tavily-search-tool) dependency `tavily-python` [PyPI ↗](https://pypi.org/project/tavily-python){:target="_blank"}
* `cli` - installs [CLI](cli.md) dependencies `rich` [PyPI ↗](https://pypi.org/project/rich){:target="_blank"}, `prompt-toolkit` [PyPI ↗](https://pypi.org/project/prompt-toolkit){:target="_blank"}, and `argcomplete` [PyPI ↗](https://pypi.org/project/argcomplete){:target="_blank"}
* `mcp` - installs [MCP](mcp/client.md) dependency `mcp` [PyPI ↗](https://pypi.org/project/mcp){:target="_blank"}
* `fastmcp` - installs [FastMCP](mcp/fastmcp-client.md) dependency `fastmcp` [PyPI ↗](https://pypi.org/project/fastmcp){:target="_blank"}
* `a2a` - installs [A2A](a2a.md) dependency `fasta2a` [PyPI ↗](https://pypi.org/project/fasta2a){:target="_blank"}
* `ui` - installs [UI Event Streams](ui/overview.md) dependency `starlette` [PyPI ↗](https://pypi.org/project/starlette){:target="_blank"}
* `ag-ui` - installs [AG-UI Event Stream Protocol](ui/ag-ui.md) dependencies `ag-ui-protocol` [PyPI ↗](https://pypi.org/project/ag-ui-protocol){:target="_blank"} and `starlette` [PyPI ↗](https://pypi.org/project/starlette){:target="_blank"}
* `dbos` - installs [DBOS Durable Execution](durable_execution/dbos.md) dependency `dbos` [PyPI ↗](https://pypi.org/project/dbos){:target="_blank"}
* `prefect` - installs [Prefect Durable Execution](durable_execution/prefect.md) dependency `prefect` [PyPI ↗](https://pypi.org/project/prefect){:target="_blank"}

You can also install dependencies for multiple models and use cases, for example:

```bash
pip/uv-add "pydantic-ai-slim[openai,vertexai,logfire]"
pip/uv-add "pydantic-ai-slim[openai,google,logfire]"
```
2 changes: 1 addition & 1 deletion docs/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ async def main():
#> {'name': 'Ben', 'dob': date(1990, 1, 28), 'bio': 'Likes the chain the '}
#> {'name': 'Ben', 'dob': date(1990, 1, 28), 'bio': 'Likes the chain the dog and the pyr'}
#> {'name': 'Ben', 'dob': date(1990, 1, 28), 'bio': 'Likes the chain the dog and the pyramid'}
#> {'name': 'Ben', 'dob': date(1990, 1, 28), 'bio': 'Likes the chain the dog and the pyramid'}
```

_(This example is complete, it can be run "as is" — you'll need to add `asyncio.run(main())` to run `main`)_
Expand Down Expand Up @@ -662,6 +661,7 @@ async def main():
#> {'name': 'Ben', 'dob': date(1990, 1, 28), 'bio': 'Likes the chain the dog and the pyr'}
#> {'name': 'Ben', 'dob': date(1990, 1, 28), 'bio': 'Likes the chain the dog and the pyramid'}
#> {'name': 'Ben', 'dob': date(1990, 1, 28), 'bio': 'Likes the chain the dog and the pyramid'}
#> {'name': 'Ben', 'dob': date(1990, 1, 28), 'bio': 'Likes the chain the dog and the pyramid'}
```

1. [`stream_responses`][pydantic_ai.result.StreamedRunResult.stream_responses] streams the data as [`ModelResponse`][pydantic_ai.messages.ModelResponse] objects, thus iteration can't fail with a `ValidationError`.
Expand Down
Loading