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)