lectom revised this gist 9 months ago. Go to revision
1 file changed, 2 deletions
agent.py
| @@ -36,5 +36,3 @@ async def main(): | |||
| 36 | 36 | ||
| 37 | 37 | if __name__ == "__main__": | |
| 38 | 38 | asyncio.run(main()) | |
| 39 | - | @LectomT | |
| 40 | - | Comment | |
lectom revised this gist 9 months ago. Go to revision
1 file changed, 40 insertions
agent.py(file created)
| @@ -0,0 +1,40 @@ | |||
| 1 | + | import asyncio | |
| 2 | + | from agents import Agent, Runner, ModelSettings | |
| 3 | + | from agents.tracing import trace | |
| 4 | + | from dotenv import load_dotenv | |
| 5 | + | ||
| 6 | + | load_dotenv() | |
| 7 | + | ||
| 8 | + | ||
| 9 | + | browser = 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 | + | ||
| 16 | + | search = Agent( | |
| 17 | + | name="Search", | |
| 18 | + | model="gpt-4o-search-preview-2025-03-11", | |
| 19 | + | instructions="You can search the web for information.", | |
| 20 | + | ) | |
| 21 | + | ||
| 22 | + | agent = Agent( | |
| 23 | + | name="Smith", | |
| 24 | + | model="gpt-4o-mini", | |
| 25 | + | instructions="You are a helpful assistant", | |
| 26 | + | handoffs=[browser, search], | |
| 27 | + | ) | |
| 28 | + | ||
| 29 | + | ||
| 30 | + | async 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 | + | ||
| 37 | + | if __name__ == "__main__": | |
| 38 | + | asyncio.run(main()) | |
| 39 | + | @LectomT | |
| 40 | + | Comment | |
Newer
Older