from pydantic import BaseModel
from agents import Agent, Runner, function_tool
import agents
import weave
import asyncio
# Weave 초기화
weave.init("openai-agents")
class Weather(BaseModel):
city: str
temperature_range: str
conditions: str
@function_tool
def get_weather(city: str) -> Weather:
# 샘플 날씨 리포트 반환
return Weather(city=city, temperature_range="14-20C", conditions="Sunny with wind.")
agent = Agent(
name="Hello world",
instructions="You are a helpful agent.",
tools=[get_weather]
)
async def main():
# 에이전트 실행
result = await Runner.run(agent, input="What's the weather in Tokyo?")
print(result.final_output)
if __name__ == "__main__":
asyncio.run(main())