Created
December 26, 2025 13:20
-
-
Save larkintuckerllc/4064a6d2d141444c25473c6686168233 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from langchain.agents import create_agent | |
| from langchain.messages import HumanMessage | |
| from langchain.tools import tool | |
| from tavily import TavilyClient | |
| tavily_client = TavilyClient(); | |
| QUESTION = HumanMessage(content="Who is the current mayor of San Francisco?") | |
| @tool | |
| def web_search(query: str) -> str: | |
| """ | |
| Search the web for information. | |
| """ | |
| return tavily_client.search(query) | |
| agent = create_agent( | |
| model="gpt-5-nano", | |
| tools=[web_search], | |
| ) | |
| response = agent.invoke({ | |
| "messages": [QUESTION], | |
| }) | |
| print(response["messages"][-1].content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment