@@ -8,17 +8,17 @@ an open protocol. Think of it as a universal translator for AI-driven systems
8
8
no matter what language an agent speaks: AG-UI ensures fluent communication.
9
9
10
10
The team at [ Rocket Science] ( https://www.rocketscience.gg/ ) , contributed the
11
- [ pydantic-ai-ag-ui ] ( #ag-ui-adapter ) package to make it easy to implement the
12
- AG-UI protocol with PydanticAI agents.
11
+ [ AG-UI integration ] ( #ag-ui-adapter ) to make it easy to implement the AG-UI
12
+ protocol with PydanticAI agents.
13
13
14
14
This also includes an [ ` Agent.to_ag_ui ` ] [ pydantic_ai.Agent.to_ag_ui ] convenience
15
- method which simplifies the creation of [ ` Adapter ` ] [ pydantic_ai_ag_ui .Adapter]
15
+ method which simplifies the creation of [ ` Adapter ` ] [ pydantic_ai.ag_ui .Adapter]
16
16
for PydanticAI agents, which can then be used by as part of a
17
17
[ fastapi] ( https://fastapi.tiangolo.com/ ) app.
18
18
19
19
## AG-UI Adapter
20
20
21
- The [ Adapter] [ pydantic_ai_ag_ui .Adapter] class is an adapter between
21
+ The [ Adapter] [ pydantic_ai.ag_ui .Adapter] class is an adapter between
22
22
PydanticAI agents and the AG-UI protocol written in Python. It provides support
23
23
for all aspects of spec including:
24
24
@@ -31,14 +31,6 @@ Let's have a quick look at how to use it:
31
31
32
32
### Installation
33
33
34
- [ Adapter] [ pydantic_ai_ag_ui.Adapter ] is available on PyPI as
35
- [ ` pydantic-ai-ag-ui ` ] ( https://pypi.org/project/pydantic-ai-ag-ui/ ) so installation is as
36
- simple as:
37
-
38
- ``` bash
39
- pip/uv-add pydantic-ai-ag-ui
40
- ```
41
-
42
34
The only dependencies are:
43
35
44
36
- [ ag-ui-protocol] ( https://docs.ag-ui.com/introduction ) : to provide the AG-UI
@@ -54,7 +46,8 @@ To run the examples you'll also need:
54
46
pip/uv-add ' fastapi'
55
47
```
56
48
57
- You can install PydanticAI with the ` ag-ui ` extra to include ** Adapter** :
49
+ You can install PydanticAI with the ` ag-ui ` extra to include
50
+ [ Adapter] [ pydantic_ai.ag_ui.Adapter ] run:
58
51
59
52
``` bash
60
53
pip/uv-add ' pydantic-ai-slim[ag-ui]'
@@ -71,7 +64,7 @@ from typing import TYPE_CHECKING, Annotated
71
64
72
65
from fastapi import FastAPI, Header
73
66
from fastapi.responses import StreamingResponse
74
- from pydantic_ai_ag_ui import SSE_CONTENT_TYPE
67
+ from pydantic_ai.ag_ui import SSE_CONTENT_TYPE
75
68
76
69
from pydantic_ai import Agent
77
70
@@ -116,7 +109,7 @@ streamed back to the caller as Server-Sent Events (SSE).
116
109
A user request may require multiple round trips between client UI and PydanticAI
117
110
server, depending on the tools and events needed.
118
111
119
- [ Adapter] [ pydantic_ai_ag_ui .Adapter] can be used with any ASGI server.
112
+ [ Adapter] [ pydantic_ai.ag_ui .Adapter] can be used with any ASGI server.
120
113
121
114
### Features
122
115
@@ -125,8 +118,8 @@ use the [`to_ag_ui`][pydantic_ai.agent.Agent.to_ag_ui] method in combination
125
118
with [ fastapi] ( https://fastapi.tiangolo.com/ ) .
126
119
127
120
In the example below we have document state which is shared between the UI and
128
- server using the [ ` StateDeps ` ] [ pydantic_ai_ag_ui .StateDeps] which implements the
129
- [ ` StateHandler ` ] [ pydantic_ai_ag_ui .StateHandler] that can be used to automatically
121
+ server using the [ ` StateDeps ` ] [ pydantic_ai.ag_ui .StateDeps] which implements the
122
+ [ ` StateHandler ` ] [ pydantic_ai.ag_ui .StateHandler] that can be used to automatically
130
123
decode state contained in [ ` RunAgentInput.state ` ] ( https://docs.ag-ui.com/sdk/js/core/types#runagentinput )
131
124
when processing requests.
132
125
@@ -146,7 +139,7 @@ from typing import TYPE_CHECKING, Annotated
146
139
from fastapi import FastAPI, Header
147
140
from fastapi.responses import StreamingResponse
148
141
from pydantic import BaseModel
149
- from pydantic_ai_ag_ui import SSE_CONTENT_TYPE , StateDeps
142
+ from pydantic_ai.ag_ui import SSE_CONTENT_TYPE , StateDeps
150
143
151
144
from pydantic_ai import Agent
152
145
@@ -187,7 +180,7 @@ uvicorn agent_to_ag_ui:app --host 0.0.0.0 --port 8000
187
180
188
181
Since the goal of [ ` to_ag_ui ` ] [ pydantic_ai.agent.Agent.to_ag_ui ] is to be a
189
182
convenience method, it accepts the same arguments as the
190
- [ ` Adapter ` ] [ pydantic_ai_ag_ui .Adapter] constructor.
183
+ [ ` Adapter ` ] [ pydantic_ai.ag_ui .Adapter] constructor.
191
184
192
185
#### Tools
193
186
@@ -213,7 +206,7 @@ from ag_ui.core import CustomEvent, EventType, StateSnapshotEvent
213
206
from fastapi import FastAPI, Header
214
207
from fastapi.responses import StreamingResponse
215
208
from pydantic import BaseModel
216
- from pydantic_ai_ag_ui import SSE_CONTENT_TYPE , StateDeps
209
+ from pydantic_ai.ag_ui import SSE_CONTENT_TYPE , StateDeps
217
210
218
211
from pydantic_ai import Agent, RunContext
219
212
@@ -272,8 +265,8 @@ async def root(
272
265
273
266
### Examples
274
267
275
- For more examples of how to use [ ` Adapter ` ] [ pydantic_ai_ag_ui .Adapter] see
276
- [ ` pydantic_ai_ag_ui_examples ` ] ( https://github.com/pydantic/pydantic-ai/tree/main/examples/pydantic_ai_ag_ui_examples ) ,
268
+ For more examples of how to use [ ` Adapter ` ] [ pydantic_ai.ag_ui .Adapter] see
269
+ [ ` pydantic_ai.ag_ui_examples ` ] ( https://github.com/pydantic/pydantic-ai/tree/main/examples/pydantic_ai.ag_ui_examples ) ,
277
270
which includes working server for the with the
278
271
[ AG-UI Dojo] ( https://docs.ag-ui.com/tutorials/debugging#the-ag-ui-dojo ) which
279
272
can be run from a clone of the repo or with the ` pydantic-ai-examples ` package
@@ -286,7 +279,7 @@ pip/uv-add pydantic-ai-examples
286
279
Direct, which supports command line flags:
287
280
288
281
``` shell
289
- python -m pydantic_ai_ag_ui_examples .dojo_server --help
282
+ python -m pydantic_ai.ag_ui_examples .dojo_server --help
290
283
usage: dojo_server.py [-h] [--port PORT] [--reload] [--no-reload] [--log-level {critical,error,warning,info,debug,trace}]
291
284
292
285
PydanticAI AG-UI Dojo server
@@ -303,11 +296,11 @@ options:
303
296
Run with adapter debug logging:
304
297
305
298
``` shell
306
- python -m pydantic_ai_ag_ui_examples .dojo_server --log-level debug
299
+ python -m pydantic_ai.ag_ui_examples .dojo_server --log-level debug
307
300
```
308
301
309
302
Using uvicorn:
310
303
311
304
``` shell
312
- uvicorn pydantic_ai_ag_ui_examples .dojo_server:app --port 9000
305
+ uvicorn pydantic_ai.ag_ui_examples .dojo_server:app --port 9000
313
306
```
0 commit comments