Skip to content

Commit d78560f

Browse files
committed
feat: add Pydantic AI integration example
- Add new Pydantic AI integration with Anthropic instrumentor - Demonstrate structured outputs with Pydantic models - Include agent tools/functions with @agent.tool decorator - Dynamic system prompts with @agent.system_prompt - Dependency injection with RunContext - Streaming responses with async iteration - Type-safe agent development patterns - Update README with Pydantic AI setup and features
1 parent b805696 commit d78560f

5 files changed

Lines changed: 369 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
- Added required criteria field to Metric model test data
1919

2020
### Added
21+
- **📚 Examples: Pydantic AI Integration**
22+
- New Pydantic AI integration with Anthropic instrumentor
23+
- Structured outputs with Pydantic models for type safety
24+
- Agent tools/functions with @agent.tool decorator
25+
- Dynamic system prompts with @agent.system_prompt
26+
- Dependency injection with RunContext
27+
- Streaming responses with async iteration
2128
- **📚 Examples: LangGraph Integration**
2229
- New LangGraph integration example with state graph workflows
2330
- Sequential node execution with conditional routing

‎docs/changelog.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ Latest Release Notes
1717
Current Version Highlights
1818
~~~~~~~~~~~~~~~~~~~~~~~~~~
1919

20+
**📚 NEW: Pydantic AI Integration Example**
21+
22+
* **Type-Safe Agents**: Complete Pydantic AI integration with structured outputs
23+
* **Agent Tools**: Demonstrates @agent.tool decorator for function calling
24+
* **Dynamic Prompts**: System prompt generation with @agent.system_prompt
25+
* **Dependency Injection**: RunContext for passing dependencies to agents
26+
* **Streaming Support**: Async iteration for streaming responses
27+
2028
**📚 NEW: LangGraph Integration Example**
2129

2230
* **State Graph Workflows**: Complete LangGraph integration with sequential node execution

‎docs/reference/index.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Core Capabilities
4848
- **Multi-Provider Support**: Simultaneous tracing across multiple LLM providers
4949
- **Token Tracking**: Automatic token usage monitoring and cost tracking
5050
- **Rich Metadata**: Detailed span attributes for AI operations
51-
- **Framework Examples**: Integration examples for OpenAI Agents (SwarmAgent), AWS Strands (TracerProvider pattern), Google ADK (async support), LangGraph (state workflows), and more
51+
- **Framework Examples**: Integration examples for OpenAI Agents (SwarmAgent), AWS Strands (TracerProvider pattern), Google ADK (async support), LangGraph (state workflows), Pydantic AI (type-safe agents), and more
5252

5353
**Performance & Reliability**:
5454

‎examples/integrations/README.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Comprehensive examples for popular AI agent frameworks:
3232
- **[`semantic_kernel_integration.py`](semantic_kernel_integration.py)** - Microsoft Semantic Kernel with OpenAI instrumentor (✅ agents, plugins, function calling, streaming)
3333
- **[`strands_integration.py`](strands_integration.py)** - AWS Strands with TracerProvider pattern (✅ Bedrock models, streaming, tools)
3434
- **[`langgraph_integration.py`](langgraph_integration.py)** - LangGraph workflows with LangChain instrumentor (✅ state graphs, conditional routing, agent graphs)
35+
- **[`pydantic_ai_integration.py`](pydantic_ai_integration.py)** - Pydantic AI agents with Anthropic instrumentor (✅ structured outputs, tools, dependencies, streaming)
3536
- **[`openinference_google_adk_example.py`](openinference_google_adk_example.py)** - Google ADK with workflow agents (✅ sequential, parallel, loop workflows)
3637

3738
## 🚀 **Quick Start**
@@ -115,6 +116,23 @@ python integrations/langgraph_integration.py
115116
- ✅ Automatic LangChain call tracing
116117
- ✅ State management across nodes
117118

119+
#### Pydantic AI
120+
```bash
121+
pip install pydantic-ai openinference-instrumentation-anthropic
122+
export ANTHROPIC_API_KEY=your-anthropic-key
123+
export HH_API_KEY=your-honeyhive-key
124+
python integrations/pydantic_ai_integration.py
125+
```
126+
127+
**Features demonstrated:**
128+
- ✅ Basic agent with instructions
129+
- ✅ Structured outputs with Pydantic models
130+
- ✅ Agent tools/functions with @agent.tool
131+
- ✅ Dynamic system prompts with @agent.system_prompt
132+
- ✅ Dependency injection with RunContext
133+
- ✅ Streaming responses with async iteration
134+
- ✅ Type-safe agent development
135+
118136
#### Google ADK
119137
```bash
120138
pip install google-adk openinference-instrumentation-google-adk

0 commit comments

Comments
 (0)