Skip to content

Commit 467bb8e

Browse files
committed
Merge branch 'main' into embeddings-api
2 parents 3dbad0d + d10df9a commit 467bb8e

File tree

263 files changed

+24644
-3588
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+24644
-3588
lines changed

.github/workflows/after-ci.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
steps:
1717
- uses: astral-sh/setup-uv@v5
1818
with:
19-
enable-cache: true
2019
python-version: "3.12"
2120

2221
- uses: dawidd6/action-download-artifact@v6
@@ -46,6 +45,10 @@ jobs:
4645
name: deploy-docs-preview
4746

4847
steps:
48+
- run: echo "$GITHUB_EVENT_JSON"
49+
env:
50+
GITHUB_EVENT_JSON: ${{ toJSON(github.event) }}
51+
4952
- uses: actions/checkout@v4
5053

5154
- uses: actions/setup-node@v4
@@ -54,20 +57,24 @@ jobs:
5457

5558
- uses: astral-sh/setup-uv@v5
5659
with:
57-
enable-cache: true
5860
python-version: "3.12"
61+
enable-cache: true
62+
cache-suffix: deploy-docs-preview
5963

60-
- uses: dawidd6/action-download-artifact@v6
64+
- id: download-artifact
65+
uses: dawidd6/action-download-artifact@v6
6166
with:
6267
workflow: ci.yml
6368
name: site
6469
path: site
6570
commit: ${{ github.event.workflow_run.head_sha }}
6671
allow_forks: true
6772
workflow_conclusion: completed
73+
if_no_artifact_found: warn
6874

6975
- uses: cloudflare/wrangler-action@v3
7076
id: deploy
77+
if: steps.download-artifact.outputs.found_artifact == 'true'
7178
with:
7279
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
7380
environment: previews
@@ -77,12 +84,9 @@ jobs:
7784
--var GIT_COMMIT_SHA:${{ github.event.workflow_run.head_sha }}
7885
--var GIT_BRANCH:${{ github.event.workflow_run.head_branch }}
7986
80-
- run: echo "$GITHUB_EVENT_JSON"
81-
env:
82-
GITHUB_EVENT_JSON: ${{ toJSON(github.event) }}
83-
8487
- name: Set preview URL
8588
run: uv run --no-project --with httpx .github/set_docs_pr_preview_url.py
89+
if: steps.deploy.outcome == 'success'
8690
env:
8791
DEPLOY_OUTPUT: ${{ steps.deploy.outputs.command-output }}
8892
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ jobs:
2626
# Typecheck both Python 3.10 and 3.13. We've had issues due to not checking against both.
2727
python-version: ["3.10", "3.13"]
2828
env:
29-
UV_PYTHON: ${{ matrix.python-version }}
3029
PYRIGHT_PYTHON: ${{ matrix.python-version }}
3130
steps:
3231
- uses: actions/checkout@v4
3332

3433
- uses: astral-sh/setup-uv@v5
3534
with:
35+
python-version: ${{ matrix.python-version }}
3636
enable-cache: true
37+
cache-suffix: lint
3738

3839
- name: Install dependencies
3940
run: uv sync --all-extras --all-packages --group lint
@@ -56,6 +57,7 @@ jobs:
5657
- uses: astral-sh/setup-uv@v5
5758
with:
5859
enable-cache: true
60+
cache-suffix: mypy
5961

6062
- name: Install dependencies
6163
run: uv sync --no-dev --group lint
@@ -70,14 +72,15 @@ jobs:
7072
- uses: astral-sh/setup-uv@v5
7173
with:
7274
enable-cache: true
75+
cache-suffix: docs
7376

7477
- run: uv sync --group docs
7578

7679
# always build docs to check it works without insiders packages
7780
- run: make docs
7881

7982
- run: make docs-insiders
80-
if: github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main'
83+
if: (github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main') && github.repository == 'pydantic/pydantic-ai'
8184
env:
8285
PPPR_TOKEN: ${{ secrets.PPPR_TOKEN }}
8386

@@ -100,13 +103,14 @@ jobs:
100103
test-live:
101104
runs-on: ubuntu-latest
102105
timeout-minutes: 5
103-
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push'
106+
if: (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') && github.repository == 'pydantic/pydantic-ai'
104107
steps:
105108
- uses: actions/checkout@v4
106109

107110
- uses: astral-sh/setup-uv@v5
108111
with:
109112
enable-cache: true
113+
cache-suffix: live
110114

111115
- uses: pydantic/ollama-action@v3
112116
with:
@@ -138,7 +142,7 @@ jobs:
138142
test:
139143
name: test on ${{ matrix.python-version }} (${{ matrix.install.name }})
140144
runs-on: ubuntu-latest
141-
timeout-minutes: 15
145+
timeout-minutes: 20
142146
strategy:
143147
fail-fast: false
144148
matrix:
@@ -151,24 +155,35 @@ jobs:
151155
- name: all-extras
152156
command: "--all-extras"
153157
env:
154-
UV_PYTHON: ${{ matrix.python-version }}
155158
CI: true
156159
COVERAGE_PROCESS_START: ./pyproject.toml
157160
steps:
158161
- uses: actions/checkout@v4
159162

160163
- uses: astral-sh/setup-uv@v5
161164
with:
165+
python-version: ${{ matrix.python-version }}
162166
enable-cache: true
167+
cache-suffix: ${{ matrix.install.name }}
163168

164169
- uses: denoland/setup-deno@v2
165170
with:
166171
deno-version: v2.x
167172

168173
- run: mkdir .coverage
169174

170-
- run: uv run mcp-run-python example --deps=numpy
171175
- run: uv sync --only-dev
176+
177+
- run: uv run mcp-run-python example --deps=numpy
178+
179+
- name: cache HuggingFace models
180+
uses: actions/cache@v4
181+
with:
182+
path: ~/.cache/huggingface
183+
key: hf-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}
184+
restore-keys: |
185+
hf-${{ runner.os }}-
186+
172187
- run: uv run ${{ matrix.install.command }} coverage run -m pytest --durations=100 -n auto --dist=loadgroup
173188
env:
174189
COVERAGE_FILE: .coverage/.coverage.${{ matrix.python-version }}-${{ matrix.install.name }}
@@ -183,21 +198,23 @@ jobs:
183198
test-lowest-versions:
184199
name: test on ${{ matrix.python-version }} (lowest-versions)
185200
runs-on: ubuntu-latest
186-
timeout-minutes: 15
201+
timeout-minutes: 20
187202
strategy:
188203
fail-fast: false
189204
matrix:
190-
python-version: ["3.10", "3.11", "3.12", "3.13"]
205+
# TODO(Marcelo): Enable 3.11 again.
206+
python-version: ["3.10", "3.12", "3.13"]
191207
env:
192-
UV_PYTHON: ${{ matrix.python-version }}
193208
CI: true
194209
COVERAGE_PROCESS_START: ./pyproject.toml
195210
steps:
196211
- uses: actions/checkout@v4
197212

198213
- uses: astral-sh/setup-uv@v5
199214
with:
215+
python-version: ${{ matrix.python-version }}
200216
enable-cache: true
217+
cache-suffix: lowest-versions
201218

202219
- uses: denoland/setup-deno@v2
203220
with:
@@ -206,8 +223,17 @@ jobs:
206223
- run: mkdir .coverage
207224

208225
- run: uv sync --group dev
226+
209227
- run: uv run mcp-run-python example --deps=numpy
210228

229+
- name: cache HuggingFace models
230+
uses: actions/cache@v4
231+
with:
232+
path: ~/.cache/huggingface
233+
key: hf-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}
234+
restore-keys: |
235+
hf-${{ runner.os }}-
236+
211237
- run: unset UV_FROZEN
212238

213239
- run: uv run --all-extras --resolution lowest-direct coverage run -m pytest --durations=100 -n auto --dist=loadgroup
@@ -230,14 +256,23 @@ jobs:
230256
matrix:
231257
python-version: ["3.11", "3.12", "3.13"]
232258
env:
233-
UV_PYTHON: ${{ matrix.python-version }}
234259
CI: true
235260
steps:
236261
- uses: actions/checkout@v4
237262

238263
- uses: astral-sh/setup-uv@v5
239264
with:
265+
python-version: ${{ matrix.python-version }}
240266
enable-cache: true
267+
cache-suffix: examples
268+
269+
- name: cache HuggingFace models
270+
uses: actions/cache@v4
271+
with:
272+
path: ~/.cache/huggingface
273+
key: hf-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}
274+
restore-keys: |
275+
hf-${{ runner.os }}-
241276
242277
- run: uv run --all-extras python tests/import_examples.py
243278

@@ -259,6 +294,7 @@ jobs:
259294
- uses: astral-sh/setup-uv@v5
260295
with:
261296
enable-cache: true
297+
cache-suffix: dev
262298

263299
- run: uv sync --group dev
264300
- run: uv run coverage combine
@@ -314,6 +350,7 @@ jobs:
314350
- uses: astral-sh/setup-uv@v5
315351
with:
316352
enable-cache: true
353+
cache-suffix: docs-upload
317354

318355
- uses: actions/download-artifact@v4
319356
with:
@@ -355,6 +392,7 @@ jobs:
355392
- uses: astral-sh/setup-uv@v5
356393
with:
357394
enable-cache: true
395+
cache-suffix: deploy-docs-preview
358396

359397
- uses: actions/download-artifact@v4
360398
with:
@@ -402,6 +440,7 @@ jobs:
402440
- uses: astral-sh/setup-uv@v5
403441
with:
404442
enable-cache: true
443+
cache-suffix: release
405444

406445
- run: uv build --all-packages
407446

.github/workflows/claude.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
- uses: astral-sh/setup-uv@v5
3838
with:
3939
enable-cache: true
40+
cache-suffix: claude-code
4041

4142
- uses: denoland/setup-deno@v2
4243
with:

.github/workflows/manually-deploy-docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
- uses: astral-sh/setup-uv@v5
1414
with:
1515
enable-cache: true
16+
cache-suffix: docs
1617

1718
- run: uv sync --group docs
1819

@@ -54,6 +55,7 @@ jobs:
5455
- uses: astral-sh/setup-uv@v5
5556
with:
5657
enable-cache: true
58+
cache-suffix: docs-upload
5759

5860
- uses: actions/download-artifact@v4
5961
with:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env*/
1010
/TODO.md
1111
/postgres-data/
1212
.DS_Store
13-
examples/pydantic_ai_examples/.chat_app_messages.sqlite
13+
.chat_app_messages.sqlite
1414
.cache/
1515
.vscode/
1616
/question_graph_history.json
@@ -21,3 +21,5 @@ node_modules/
2121
/test_tmp/
2222
.mcp.json
2323
.claude/
24+
/.cursor/
25+
/.devcontainer/

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
2828

2929
**Model Integration (`pydantic_ai_slim/pydantic_ai/models/`)**
3030
- Unified interface across providers: OpenAI, Anthropic, Google, Groq, Cohere, Mistral, Bedrock, HuggingFace
31-
- Model strings: `"openai:gpt-4o"`, `"anthropic:claude-3-5-sonnet"`, `"google:gemini-1.5-pro"`
31+
- Model strings: `"openai:gpt-5"`, `"anthropic:claude-sonnet-4-5"`, `"google:gemini-2.5-pro"`
3232
- `ModelRequestParameters` for configuration, `StreamedResponse` for streaming
3333

3434
**Graph-based Execution (`pydantic_graph/` + `_agent_graph.py`)**
@@ -55,7 +55,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
5555
class MyDeps:
5656
database: DatabaseConn
5757

58-
agent = Agent('openai:gpt-4o', deps_type=MyDeps)
58+
agent = Agent('openai:gpt-5', deps_type=MyDeps)
5959

6060
@agent.tool
6161
async def get_data(ctx: RunContext[MyDeps]) -> str:
@@ -69,7 +69,7 @@ class OutputModel(BaseModel):
6969
confidence: float
7070

7171
agent: Agent[MyDeps, OutputModel] = Agent(
72-
'openai:gpt-4o',
72+
'openai:gpt-5',
7373
deps_type=MyDeps,
7474
output_type=OutputModel
7575
)

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ typecheck-both: typecheck-pyright typecheck-mypy
5353
.PHONY: test
5454
test: ## Run tests and collect coverage data
5555
@# To test using a specific version of python, run 'make install-all-python' then set environment variable PYTEST_PYTHON=3.10 or similar
56-
$(if $(PYTEST_PYTHON),UV_PROJECT_ENVIRONMENT=.venv$(subst .,,$(PYTEST_PYTHON))) uv run $(if $(PYTEST_PYTHON),--python $(PYTEST_PYTHON)) coverage run -m pytest -n auto --dist=loadgroup --durations=20
56+
COLUMNS=150 $(if $(PYTEST_PYTHON),UV_PROJECT_ENVIRONMENT=.venv$(subst .,,$(PYTEST_PYTHON))) uv run $(if $(PYTEST_PYTHON),--python $(PYTEST_PYTHON)) coverage run -m pytest -n auto --dist=loadgroup --durations=20
5757
@uv run coverage combine
5858
@uv run coverage report
5959

6060
.PHONY: test-all-python
6161
test-all-python: ## Run tests on Python 3.10 to 3.13
62-
UV_PROJECT_ENVIRONMENT=.venv310 uv run --python 3.10 --all-extras --all-packages coverage run -p -m pytest
63-
UV_PROJECT_ENVIRONMENT=.venv311 uv run --python 3.11 --all-extras --all-packages coverage run -p -m pytest
64-
UV_PROJECT_ENVIRONMENT=.venv312 uv run --python 3.12 --all-extras --all-packages coverage run -p -m pytest
65-
UV_PROJECT_ENVIRONMENT=.venv313 uv run --python 3.13 --all-extras --all-packages coverage run -p -m pytest
62+
COLUMNS=150 UV_PROJECT_ENVIRONMENT=.venv310 uv run --python 3.10 --all-extras --all-packages coverage run -p -m pytest
63+
COLUMNS=150 UV_PROJECT_ENVIRONMENT=.venv311 uv run --python 3.11 --all-extras --all-packages coverage run -p -m pytest
64+
COLUMNS=150 UV_PROJECT_ENVIRONMENT=.venv312 uv run --python 3.12 --all-extras --all-packages coverage run -p -m pytest
65+
COLUMNS=150 UV_PROJECT_ENVIRONMENT=.venv313 uv run --python 3.13 --all-extras --all-packages coverage run -p -m pytest
6666
@uv run coverage combine
6767
@uv run coverage report
6868

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ We built Pydantic AI with one simple aim: to bring that FastAPI feeling to GenAI
3939
[Pydantic Validation](https://docs.pydantic.dev/latest/) is the validation layer of the OpenAI SDK, the Google ADK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, CrewAI, Instructor and many more. _Why use the derivative when you can go straight to the source?_ :smiley:
4040

4141
2. **Model-agnostic**:
42-
Supports virtually every [model](https://ai.pydantic.dev/models/overview) and provider: OpenAI, Anthropic, Gemini, DeepSeek, Grok, Cohere, Mistral, and Perplexity; Azure AI Foundry, Amazon Bedrock, Google Vertex AI, Ollama, LiteLLM, Groq, OpenRouter, Together AI, Fireworks AI, Cerebras, Hugging Face, GitHub, Heroku, Vercel, Nebius, OVHcloud. If your favorite model or provider is not listed, you can easily implement a [custom model](https://ai.pydantic.dev/models/overview#custom-models).
42+
Supports virtually every [model](https://ai.pydantic.dev/models/overview) and provider: OpenAI, Anthropic, Gemini, DeepSeek, Grok, Cohere, Mistral, and Perplexity; Azure AI Foundry, Amazon Bedrock, Google Vertex AI, Ollama, LiteLLM, Groq, OpenRouter, Together AI, Fireworks AI, Cerebras, Hugging Face, GitHub, Heroku, Vercel, Nebius, OVHcloud, and Outlines. If your favorite model or provider is not listed, you can easily implement a [custom model](https://ai.pydantic.dev/models/overview#custom-models).
4343

4444
3. **Seamless Observability**:
4545
Tightly [integrates](https://ai.pydantic.dev/logfire) with [Pydantic Logfire](https://pydantic.dev/logfire), our general-purpose OpenTelemetry observability platform, for real-time debugging, evals-based performance monitoring, and behavior, tracing, and cost tracking. If you already have an observability platform that supports OTel, you can [use that too](https://ai.pydantic.dev/logfire#alternative-observability-backends).
@@ -50,8 +50,8 @@ Designed to give your IDE or AI coding agent as much context as possible for aut
5050
5. **Powerful Evals**:
5151
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.
5252

53-
6. **MCP, A2A, and AG-UI**:
54-
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.
53+
6. **MCP, A2A, and UI**:
54+
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.
5555

5656
7. **Human-in-the-Loop Tool Approval**:
5757
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.

clai/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ positional arguments:
7070
options:
7171
-h, --help show this help message and exit
7272
-m [MODEL], --model [MODEL]
73-
Model to use, in format "<provider>:<model>" e.g. "openai:gpt-4.1" or "anthropic:claude-sonnet-4-0". Defaults to "openai:gpt-4.1".
73+
Model to use, in format "<provider>:<model>" e.g. "openai:gpt-5" or "anthropic:claude-sonnet-4-5". Defaults to "openai:gpt-5".
7474
-a AGENT, --agent AGENT
7575
Custom Agent to use, in format "module:variable", e.g. "mymodule.submodule:my_agent"
7676
-l, --list-models List all available models and exit

docs-site/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const redirect_lookup: Record<string, string> = {
5555
'/examples': 'examples/setup/',
5656
'/mcp': '/mcp/overview/',
5757
'/models': '/models/overview/',
58+
'/ag-ui': '/ui/ag-ui/'
5859
}
5960

6061
function redirect(pathname: string): string | null {

0 commit comments

Comments
 (0)