Skip to content

Instantly share code, notes, and snippets.

@larkintuckerllc
Created December 26, 2025 13:20
Show Gist options
  • Select an option

  • Save larkintuckerllc/4064a6d2d141444c25473c6686168233 to your computer and use it in GitHub Desktop.

Select an option

Save larkintuckerllc/4064a6d2d141444c25473c6686168233 to your computer and use it in GitHub Desktop.
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