Skip to content

Commit d6c4616

Browse files
committed
chore(ag-ui): python 3.9 support
Eliminate the use of match statement and dataclass(kw_only=True) to ensure compatibility with Python 3.9. Remove duplicate import of starlette outside try block, causing tests to fail when it's not installed.
1 parent 511814f commit d6c4616

File tree

9 files changed

+361
-344
lines changed

9 files changed

+361
-344
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ jobs:
204204
enable-cache: true
205205

206206
- run: uv sync --package pydantic-ai-slim --only-dev
207+
- run: rm coverage/.coverage.*-py3.9-* # Exclude 3.9 coverage as it gets the wrong line numbers, causing invalid failures.
207208
- run: uv run coverage combine coverage
208209

209210
- run: uv run coverage html --show-contexts --title "PydanticAI coverage for ${{ github.sha }}"

docs/ag-ui.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def custom_events() -> list[CustomEvent]:
225225
### Examples
226226

227227
For more examples of how to use [`Adapter`][pydantic_ai.ag_ui.Adapter] see
228-
[`pydantic_ai.ag_ui_examples`](https://github.com/pydantic/pydantic-ai/tree/main/examples/pydantic_ai.ag_ui_examples),
228+
[`pydantic_ai_ag_ui_examples`](https://github.com/pydantic/pydantic-ai/tree/main/examples/pydantic_ai_ag_ui_examples),
229229
which includes working server for the with the
230230
[AG-UI Dojo](https://docs.ag-ui.com/tutorials/debugging#the-ag-ui-dojo) which
231231
can be run from a clone of the repo or with the `pydantic-ai-examples` package
@@ -238,7 +238,7 @@ pip/uv-add pydantic-ai-examples
238238
Direct, which supports command line flags:
239239

240240
```shell
241-
python -m pydantic_ai.ag_ui_examples.dojo_server --help
241+
python -m pydantic_ai_ag_ui_examples.dojo_server --help
242242
usage: dojo_server.py [-h] [--port PORT] [--reload] [--no-reload] [--log-level {critical,error,warning,info,debug,trace}]
243243

244244
PydanticAI AG-UI Dojo server

examples/pydantic_ai_ag_ui_examples/README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,36 @@ Implementation of the AG-UI protocol for PydanticAI.
77
This example uses a PydanticAI agent using an OpenAI model and the AG-UI dojo.
88

99
1. An [OpenAI API key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key)
10-
2. A clone of this repository
11-
3. A clone of the [AG-UI protocol repository](https://github.com/ag-ui-protocol/ag-ui)
10+
2. A clone of the [AG-UI protocol repository](https://github.com/ag-ui-protocol/ag-ui)
1211

1312
## Running
1413

1514
To run this integration you need to:
1615

17-
1. Make a copy of `jobs-agent/.env.local-example` as `.env`
16+
1. Make a copy of `.env-sample` as `.env` in the `typescript-sdk/integrations/pydantic-ai` directory
1817
2. Open it in your editor and set `OPENAI_API_KEY` to a valid OpenAI key
19-
3. Open terminal in the root directory of this repository clone
20-
4. Install the required modules and run the server
18+
3. Open terminal in the `typescript-sdk/integrations/pydantic-ai` of the `ag-ui` repo
19+
4. Install the `pydantic-ai-examples` package
2120

2221
```shell
23-
cd jobs-agent
24-
just install-deps
25-
source .venv/bin/activate
26-
python -m examples.pydantic_ai_ag_ui_examples.dojo_server
22+
pip/uv-add pydantic-ai-examples
2723
```
2824

29-
5. Open another terminal in root directory of the `ag-ui` repository clone
30-
6. Start the integration ag-ui dojo:
25+
5. Run the example dojo server
26+
27+
```shell
28+
python -m pydantic_ai_ag_ui_examples.dojo_server
29+
```
30+
31+
6. Open another terminal in root directory of the `ag-ui` repository clone
32+
7. Start the integration ag-ui dojo:
3133

3234
```shell
3335
cd typescript-sdk
3436
pnpm install && pnpm run dev
3537
```
3638

37-
7. Finally visit [http://localhost:3000/pydantic-ai](http://localhost:3000/pydantic-ai)
39+
8. Finally visit [http://localhost:3000/pydantic-ai](http://localhost:3000/pydantic-ai)
3840

3941
## Feature Demos
4042

@@ -97,7 +99,8 @@ Generate a list of steps for cleaning a car for me to review
9799
### [Predictive State Updates](http://localhost:3000/pydantic-ai/feature/predictive_state_updates)
98100
99101
Demonstrates how to use the predictive state updates feature to update the state
100-
of the UI based on agent responses, including user interaction via git aconfirmation.
102+
of the UI based on agent responses, including user interaction via user
103+
confirmation.
101104
102105
#### Story Tools
103106

0 commit comments

Comments
 (0)