Skip to content

Commit 653aca1

Browse files
authored
Merge branch 'main' into add-googlemodel-google-specific-error-handling
2 parents 73ba23e + 4cc4f35 commit 653aca1

File tree

216 files changed

+17220
-2546
lines changed

Some content is hidden

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

216 files changed

+17220
-2546
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: 45 additions & 7 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,6 +72,7 @@ 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

@@ -107,6 +110,7 @@ jobs:
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,22 @@ 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:
190205
python-version: ["3.10", "3.11", "3.12", "3.13"]
191206
env:
192-
UV_PYTHON: ${{ matrix.python-version }}
193207
CI: true
194208
COVERAGE_PROCESS_START: ./pyproject.toml
195209
steps:
196210
- uses: actions/checkout@v4
197211

198212
- uses: astral-sh/setup-uv@v5
199213
with:
214+
python-version: ${{ matrix.python-version }}
200215
enable-cache: true
216+
cache-suffix: lowest-versions
201217

202218
- uses: denoland/setup-deno@v2
203219
with:
@@ -206,8 +222,17 @@ jobs:
206222
- run: mkdir .coverage
207223

208224
- run: uv sync --group dev
225+
209226
- run: uv run mcp-run-python example --deps=numpy
210227

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

213238
- run: uv run --all-extras --resolution lowest-direct coverage run -m pytest --durations=100 -n auto --dist=loadgroup
@@ -230,14 +255,23 @@ jobs:
230255
matrix:
231256
python-version: ["3.11", "3.12", "3.13"]
232257
env:
233-
UV_PYTHON: ${{ matrix.python-version }}
234258
CI: true
235259
steps:
236260
- uses: actions/checkout@v4
237261

238262
- uses: astral-sh/setup-uv@v5
239263
with:
264+
python-version: ${{ matrix.python-version }}
240265
enable-cache: true
266+
cache-suffix: examples
267+
268+
- name: cache HuggingFace models
269+
uses: actions/cache@v4
270+
with:
271+
path: ~/.cache/huggingface
272+
key: hf-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}
273+
restore-keys: |
274+
hf-${{ runner.os }}-
241275
242276
- run: uv run --all-extras python tests/import_examples.py
243277

@@ -259,6 +293,7 @@ jobs:
259293
- uses: astral-sh/setup-uv@v5
260294
with:
261295
enable-cache: true
296+
cache-suffix: dev
262297

263298
- run: uv sync --group dev
264299
- run: uv run coverage combine
@@ -314,6 +349,7 @@ jobs:
314349
- uses: astral-sh/setup-uv@v5
315350
with:
316351
enable-cache: true
352+
cache-suffix: docs-upload
317353

318354
- uses: actions/download-artifact@v4
319355
with:
@@ -355,6 +391,7 @@ jobs:
355391
- uses: astral-sh/setup-uv@v5
356392
with:
357393
enable-cache: true
394+
cache-suffix: deploy-docs-preview
358395

359396
- uses: actions/download-artifact@v4
360397
with:
@@ -402,6 +439,7 @@ jobs:
402439
- uses: astral-sh/setup-uv@v5
403440
with:
404441
enable-cache: true
442+
cache-suffix: release
405443

406444
- run: uv build --all-packages
407445

.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: 1 addition & 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

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
)

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 {

docs-site/wrangler.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ compatibility_date = "2025-06-17"
44
routes = ["ai.pydantic.dev/*"]
55
main = "src/index.ts"
66
workers_dev = false
7+
preview_urls = true
78
compatibility_flags = [ "nodejs_compat_v2" ]
89

910
[vars]

0 commit comments

Comments
 (0)