forked from openai/openai-agents-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb_search.py
More file actions
23 lines (17 loc) · 671 Bytes
/
Copy pathweb_search.py
File metadata and controls
23 lines (17 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import asyncio
from agents import Agent, Runner, WebSearchTool, trace
async def main():
agent = Agent(
name="Web searcher",
instructions="You are a helpful agent.",
tools=[WebSearchTool(user_location={"type": "approximate", "city": "New York"})],
)
with trace("Web search example"):
result = await Runner.run(
agent,
"search the web for 'local sports news' and give me 1 interesting update in a sentence.",
)
print(result.final_output)
# The New York Giants are reportedly pursuing quarterback Aaron Rodgers after his ...
if __name__ == "__main__":
asyncio.run(main())