Created
December 26, 2025 12:27
-
-
Save larkintuckerllc/42289587f8c505accdeecd593d6fe280 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 | |
| QUESTION = HumanMessage(content="What's the square root of 467?") | |
| SYSTEM_PROMPT = "You are an arithmetic wizard." | |
| @tool | |
| def square_root(x: float) -> float: | |
| """ | |
| Calculate the square root of a number. | |
| """ | |
| return x ** 0.5 | |
| agent = create_agent( | |
| model="gpt-5-nano", | |
| system_prompt=SYSTEM_PROMPT, | |
| tools=[square_root], | |
| ) | |
| 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