from pydantic_ai import Agent
from pydantic_ai.models.instrumented import InstrumentationSettings
# system prompt와 OTEL 트레이싱으로 PydanticAI 에이전트 생성
agent = Agent(
"openai:gpt-4o",
system_prompt=(
"You are a helpful assistant that can multiply numbers. "
"When asked to multiply numbers, use the multiply tool."
),
instrument=InstrumentationSettings(tracer_provider=tracer_provider),
)
# 도구 정의
@agent.tool_plain
def multiply(a: int, b: int) -> int:
"""Multiply two numbers."""
return a * b
# 에이전트에게 도구 사용 요청
result = agent.run_sync("What is 7 multiplied by 8?")
print(result.output)