最后活跃于 1741748041

agent.py 原始文件
1import asyncio
2from agents import Agent, Runner, ModelSettings
3from agents.tracing import trace
4from dotenv import load_dotenv
5
6load_dotenv()
7
8
9browser = Agent(
10 name="Browser",
11 model="computer-use-preview-2025-03-11",
12 model_settings=ModelSettings(truncation="auto"),
13 instructions="You can do tasks like searching the web, running code, and more.",
14)
15
16search = Agent(
17 name="Search",
18 model="gpt-4o-search-preview-2025-03-11",
19 instructions="You can search the web for information.",
20)
21
22agent = Agent(
23 name="Smith",
24 model="gpt-4o-mini",
25 instructions="You are a helpful assistant",
26 handoffs=[browser, search],
27)
28
29
30async def main():
31 prompt = input("Enter a prompt: ")
32 with trace(workflow_name="agent_smith"):
33 result = await Runner.run(agent, prompt)
34 print(result.final_output)
35
36
37if __name__ == "__main__":
38 asyncio.run(main())
39