AI Agent Development with Pydantic AI

Karim Khattaby

AI Agent That Builds AI Agents

An AI agent that leverages Pydantic AI documentation to build AI agents

Screenshots

Functionality

Multi-agent architecture built using Pydantic AI, LangGraph, and LangChain
Agents that coordinate reasoning (with qwen3), tool use, code writing (with qwen2.5 coder) and output formatting
Agentic RAG pipeline integrating Supabase for indexing and retrieval, with a script that crawls the entire Pydantic AI documentation
Observability and tracing using Langfuse
Streamlit frontend to interact with the agent
Deployed locally using Docker for frontend and database, and LM studio (with ollama) to serve models

Agent Orchestration Diagram

Tech Stack

Front-end: Streamlit Models: LLMs and embeddings Database: Supabase

Frameworks

Pydantic AI (for agents)
Langchain (for summarizing content with LLM and interacting with embeddings models)
LangGraph
Langfuse (for observability and tracing)
Supabase
Crawl4AI (for crawling documentation content)
Streamlit

Installation

Clone this repo
Create and activate a virtual environment
Run pip install -r requirements.txt
Spin up supabase locally or create a project on the cloud
Spin up langfuse locally or create a project on the cloud
Rename .env.example to .env and add the necessary variables
Run python crawl_pydantic_ai_docs.py to crawl and index the documentation
Run Streamlit run streamlit_ui.py to start talking with the agent

My Local Testing Setup

I tested everything on a local setup using LM studio to serve Qwen3 8B for reasoning, Qwen2.5 Coder 7B Instruct for code generation, and Text Embedding Nomic Embed Text v1.5 for embeddings generation. Along with a docker deployed instance of supabase and langfuse. Here's why I changed from Llama 3.2 3B Instruct to Qwen:
Qwen3 8B was giving me much better results with reasoning, especially after I fixed the bug with <think> tags for tooling, I wanted to test Deepseek R1 Distill Llama 8B but Qwen is already giving really good results so it became unnecessary to explore.
Upgrading from QnA to code generation required using an LLM that is specifically trained for code generation and Qwen2.5 is a very powerful model at that (maybe not as powerful as Devstral but the 7B version is definitely the best my machine could handle, also it's already giving me very good results so I felt no need to explore other options). I tried using Qwen3 for code generation too but the model was getting stuck in an infinite loop of tooling calls.
As for embeddings, I tried Bge Large En v1.5 but it kept crashing due to local setup limitations.

Usage

Once the UI is up and running, streamlit should automatically open a browser window with the agent, or at least print the URL in the terminal
Talk to the agent and ask it to code an agent
After the model responds, you can check traces on langfuse dashboard

Example Run

Like this project

Posted Jun 7, 2025

Developed an AI agent using Pydantic AI, LangGraph, and LangChain with a Streamlit frontend, Supabase integration and Langfuse for observability.

Join 50k+ companies and 1M+ independents

Contra Logo

© 2025 Contra.Work Inc