diff --git a/src/lib/navigation.ts b/src/lib/navigation.ts index f8c26b39..e44fb227 100644 --- a/src/lib/navigation.ts +++ b/src/lib/navigation.ts @@ -427,6 +427,7 @@ export const tabNavigation: NavTab[] = [ { title: 'DSPy', href: '/docs/tracing/auto/dspy' }, { title: 'OpenAI Agents', href: '/docs/tracing/auto/openai_agents' }, { title: 'Smol Agents', href: '/docs/tracing/auto/smol_agents' }, + { title: 'Pydantic AI', href: '/docs/tracing/auto/pydantic_ai' }, { title: 'Instructor', href: '/docs/tracing/auto/instructor' }, { title: 'PromptFlow', href: '/docs/tracing/auto/promptflow' }, { title: 'Guardrails', href: '/docs/tracing/auto/guardrails' }, @@ -659,6 +660,7 @@ export const tabNavigation: NavTab[] = [ { title: 'DSPy', href: '/docs/integrations/traceai/dspy' }, { title: 'OpenAI Agents', href: '/docs/integrations/traceai/openai_agents' }, { title: 'Smol Agents', href: '/docs/integrations/traceai/smol_agents' }, + { title: 'Pydantic AI', href: '/docs/integrations/traceai/pydantic_ai' }, { title: 'Instructor', href: '/docs/integrations/traceai/instructor' }, { title: 'PromptFlow', href: '/docs/integrations/traceai/promptflow' }, { title: 'Guardrails', href: '/docs/integrations/traceai/guardrails' }, diff --git a/src/pages/docs/integrations/index.mdx b/src/pages/docs/integrations/index.mdx index c61343f7..0206ef6c 100644 --- a/src/pages/docs/integrations/index.mdx +++ b/src/pages/docs/integrations/index.mdx @@ -40,6 +40,7 @@ TraceAI provides pre-built auto-instrumentation for the following frameworks and + diff --git a/src/pages/docs/integrations/traceai/pydantic_ai.mdx b/src/pages/docs/integrations/traceai/pydantic_ai.mdx new file mode 100644 index 00000000..2e1f1ed9 --- /dev/null +++ b/src/pages/docs/integrations/traceai/pydantic_ai.mdx @@ -0,0 +1,72 @@ +--- +title: "Pydantic AI Integration with Future AGI for Agent Observability" +description: "Integrate Pydantic AI with Future AGI observability. Trace agent runs, tool calls, structured outputs, and streaming automatically using traceAI-pydantic-ai." +--- + +## 1. Installation +Install the traceAI and other necessary packages. + +```bash +pip install traceAI-pydantic-ai pydantic-ai +``` + +--- + +## 2. Set Environment Variables +Set up your environment variables to authenticate with FutureAGI. + +```python +import os + +os.environ["OPENAI_API_KEY"] = "your-openai-api-key" +os.environ["FI_API_KEY"] = "your-futureagi-api-key" +os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key" +``` + +--- + +## 3. Initialize Trace Provider +Set up the trace provider to create a new project in FutureAGI, establish telemetry data pipelines . + +```python +from fi_instrumentation import register +from fi_instrumentation.fi_types import ProjectType + +trace_provider = register( + project_type=ProjectType.OBSERVE, + project_name="PYDANTIC_AI_APP", +) +``` + +--- + +## 4. Instrument your Project +Use the Pydantic AI Instrumentor to instrument your project. + +```python +from traceai_pydantic_ai import PydanticAIInstrumentor + +PydanticAIInstrumentor().instrument(tracer_provider=trace_provider) +``` + +--- + +## 5. Run your Pydantic AI application. +Run your Pydantic AI application as you normally would. Our Instrumentor will automatically trace and send the telemetry data to our platform. + +```python +from pydantic_ai import Agent, RunContext + +agent = Agent( + "openai:gpt-4o", + instructions="You are a helpful assistant.", +) + +@agent.tool +def get_weather(ctx: RunContext, city: str) -> str: + """Get the weather for a city.""" + return f"The weather in {city} is sunny and 72F" + +result = agent.run_sync("What is the weather in San Francisco?") +print(result.output) +``` diff --git a/src/pages/docs/tracing/auto/index.mdx b/src/pages/docs/tracing/auto/index.mdx index 9eb6e48e..28d8afcd 100644 --- a/src/pages/docs/tracing/auto/index.mdx +++ b/src/pages/docs/tracing/auto/index.mdx @@ -83,6 +83,9 @@ Python and JS/TS integrations use instrumentors that patch client libraries. Jav `traceAI-smolagents` + + `traceAI-pydantic-ai` + `traceAI-instructor` diff --git a/src/pages/docs/tracing/auto/pydantic_ai.mdx b/src/pages/docs/tracing/auto/pydantic_ai.mdx new file mode 100644 index 00000000..50b1feed --- /dev/null +++ b/src/pages/docs/tracing/auto/pydantic_ai.mdx @@ -0,0 +1,72 @@ +--- +title: "Pydantic AI Tracing with Future AGI: Auto-Instrumentation" +description: "Set up auto-instrumentation for Pydantic AI with Future AGI tracing. Install traceAI-pydantic-ai to capture agent runs, tool calls, and model interactions." +--- + +## 1. Installation +Install the traceAI and other necessary packages. + +```bash +pip install traceAI-pydantic-ai pydantic-ai +``` + +--- + +## 2. Set Environment Variables +Set up your environment variables to authenticate with FutureAGI. + +```python +import os + +os.environ["OPENAI_API_KEY"] = "your-openai-api-key" +os.environ["FI_API_KEY"] = "your-futureagi-api-key" +os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key" +``` + +--- + +## 3. Initialize Trace Provider +Set up the trace provider to create a new project in FutureAGI, establish telemetry data pipelines . + +```python +from fi_instrumentation import register +from fi_instrumentation.fi_types import ProjectType + +trace_provider = register( + project_type=ProjectType.OBSERVE, + project_name="PYDANTIC_AI_APP", +) +``` + +--- + +## 4. Instrument your Project +Use the Pydantic AI Instrumentor to instrument your project. + +```python +from traceai_pydantic_ai import PydanticAIInstrumentor + +PydanticAIInstrumentor().instrument(tracer_provider=trace_provider) +``` + +--- + +## 5. Run your Pydantic AI application. +Run your Pydantic AI application as you normally would. Our Instrumentor will automatically trace and send the telemetry data to our platform. + +```python +from pydantic_ai import Agent, RunContext + +agent = Agent( + "openai:gpt-4o", + instructions="You are a helpful assistant.", +) + +@agent.tool +def get_weather(ctx: RunContext, city: str) -> str: + """Get the weather for a city.""" + return f"The weather in {city} is sunny and 72F" + +result = agent.run_sync("What is the weather in San Francisco?") +print(result.output) +```