Skip to content

pythonpete32/pydantic-agents

Repository files navigation

Pydantic Agents

CI Python 3.10+ License: MIT Code style: black Ruff

A collection of agents using PydanticAI.

Features

  • 🤖 Agents showcasing PydanticAI capabilities
  • 📊 Logfire integration for monitoring
  • 🛠️ Modern development tools (black, isort, ruff, mypy)
  • 📦 UV package management
  • 🧪 Testing setup with pytest

Requirements

  • Python 3.10+
  • UV package manager
  • Make (optional, for using Makefile commands)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/pydantic-agents.git
cd pydantic-agents
  1. Create and activate a virtual environment:
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install the package with development dependencies:
uv pip install -e ".[dev]"

Demo Agents

Hello World Agent

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)

Bank Support Agent

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...",
)

Development Commands

The project includes a Makefile with common development tasks:

  • make install: Install the package and development dependencies
  • make format: Format code with black and isort
  • make lint: Run all linting checks (ruff, black, isort, mypy)
  • make test: Run tests with pytest

Project Structure

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

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Agentic design patterns with Pydantic AI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published