A collection of agents using PydanticAI.
- 🤖 Agents showcasing PydanticAI capabilities
- 📊 Logfire integration for monitoring
- 🛠️ Modern development tools (black, isort, ruff, mypy)
- 📦 UV package management
- 🧪 Testing setup with pytest
- Python 3.10+
- UV package manager
- Make (optional, for using Makefile commands)
- Clone the repository:
git clone https://github.com/yourusername/pydantic-agents.git
cd pydantic-agents
- Create and activate a virtual environment:
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install the package with development dependencies:
uv pip install -e ".[dev]"
A simple agent that demonstrates basic PydanticAI usage:
from pydantic_ai import Agent
agent = Agent(
"gemini-1.5-flash",
system_prompt="Be concise, reply with one sentence.",
)
result = agent.run_sync("Where does 'hello world' come from?")
print(result.data)
A more complex example showing dependency injection and tools:
from pydantic_ai import Agent, RunContext
from pydantic import BaseModel, Field
class SupportResult(BaseModel):
support_advice: str
block_card: bool
risk: int
support_agent = Agent(
"openai:gpt-4",
result_type=SupportResult,
system_prompt="You are a bank support agent...",
)
The project includes a Makefile with common development tasks:
make install
: Install the package and development dependenciesmake format
: Format code with black and isortmake lint
: Run all linting checks (ruff, black, isort, mypy)make test
: Run tests with pytest
pydantic-agents/
├── src/
│ ├── __init__.py
│ ├── main.py
│ └── agents/
│ ├── __init__.py
│ └── bank_support.py
├── tests/
│ └── __init__.py
├── .env.example
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
└── pyproject.toml
This project is licensed under the MIT License - see the LICENSE file for details.