Skip to content

Commit 6ae0dc0

Browse files
committed
Make work without local pydantic repo
1 parent c12ba91 commit 6ae0dc0

File tree

5 files changed

+2596
-9
lines changed

5 files changed

+2596
-9
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Pydantic AI AG-UI Examples
2+
3+
This directory contains example usage of the AG-UI adapter for Pydantic AI. It provides a FastAPI application that demonstrates how to use the Pydantic AI agent with the AG-UI protocol.
4+
5+
## Features
6+
7+
The examples include implementations for each of the AG-UI dojo features:
8+
- Agentic Chat
9+
- Human in the Loop
10+
- Agentic Generative UI
11+
- Tool Based Generative UI
12+
- Shared State
13+
- Predictive State Updates
14+
15+
## Setup
16+
17+
### Using uv (Recommended)
18+
19+
1. Install dependencies:
20+
```bash
21+
uv sync
22+
```
23+
24+
2. Run the development server:
25+
```bash
26+
uv run dev
27+
```
28+
29+
### Using pip
30+
31+
1. Install dependencies:
32+
```bash
33+
pip install -r requirements.txt
34+
```
35+
36+
2. Run the development server:
37+
```bash
38+
python -m pydantic_ai_examples
39+
```
40+
41+
## Usage
42+
43+
Once the server is running, you can access the different examples at:
44+
45+
- `http://localhost:9000/agentic_chat` - Agentic Chat
46+
- `http://localhost:9000/agentic_generative_ui` - Agentic Generative UI
47+
- `http://localhost:9000/human_in_the_loop` - Human in the Loop
48+
- `http://localhost:9000/predictive_state_updates` - Predictive State Updates
49+
- `http://localhost:9000/shared_state` - Shared State
50+
- `http://localhost:9000/tool_based_generative_ui` - Tool Based Generative UI
51+
52+
## Development
53+
54+
To install development dependencies:
55+
56+
```bash
57+
uv sync --extra dev
58+
```
59+
60+
This will install additional tools for testing, formatting, and type checking.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[build-system]
2+
requires = ["hatchling", "uv-dynamic-versioning>=0.7.0"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "server"
7+
version = "0.1.0"
8+
description = "Example usage of the AG-UI adapter for Pydantic AI"
9+
license = "MIT"
10+
11+
readme = "README.md"
12+
requires-python = ">=3.9"
13+
dependencies = [
14+
"fastapi>=0.104.0",
15+
"uvicorn[standard]>=0.24.0",
16+
"pydantic-ai>=0.1.0",
17+
]
18+
authors = [
19+
{ name = "Samuel Colvin", email = "[email protected]" },
20+
{ name = "Marcelo Trylesinski", email = "[email protected]" },
21+
{ name = "David Montague", email = "[email protected]" },
22+
{ name = "Alex Hall", email = "[email protected]" },
23+
{ name = "Douwe Maan", email = "[email protected]" },
24+
]
25+
26+
[tool.hatch.metadata.hooks.uv-dynamic-versioning]
27+
dependencies = [
28+
"pydantic-ai-slim[openai,vertexai,groq,anthropic,ag-ui]=={{ version }}",
29+
"pydantic-evals=={{ version }}",
30+
"asyncpg>=0.30.0",
31+
"fastapi>=0.115.4",
32+
"logfire[asyncpg,fastapi,sqlite3,httpx]>=2.6",
33+
"python-multipart>=0.0.17",
34+
"rich>=13.9.2",
35+
"uvicorn>=0.32.0",
36+
"devtools>=0.12.2",
37+
"gradio>=5.9.0; python_version>'3.9'",
38+
"mcp[cli]>=1.4.1; python_version >= '3.10'",
39+
"modal>=1.0.4",
40+
]
41+
42+
43+
[tool.hatch.build.targets.sdist]
44+
include = ["server/"]
45+
46+
[tool.hatch.build.targets.wheel]
47+
include = ["server/"]
48+
49+
[project.scripts]
50+
dev = "server:main"
51+

typescript-sdk/integrations/pydantic-ai/examples/server/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from __future__ import annotations
1515

1616
from fastapi import FastAPI
17+
import uvicorn
18+
1719

1820
from .api import (
1921
agentic_chat_app,
@@ -39,3 +41,13 @@
3941
tool_based_generative_ui_app,
4042
'Tool Based Generative UI',
4143
)
44+
45+
46+
def main():
47+
"""Main function to start the FastAPI server."""
48+
uvicorn.run(app, host="0.0.0.0", port=9000)
49+
50+
if __name__ == "__main__":
51+
main()
52+
53+
__all__ = ["main"]

typescript-sdk/integrations/pydantic-ai/examples/server/__main__.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)