tools_runner.py — anthropic-sdk-python Source File
Architecture documentation for tools_runner.py, a python file in the anthropic-sdk-python codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR f256b1e3_d2b3_ac5c_1d2c_4432a530febc["tools_runner.py"] 28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5["json"] f256b1e3_d2b3_ac5c_1d2c_4432a530febc --> 28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5 37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"] f256b1e3_d2b3_ac5c_1d2c_4432a530febc --> 37c05070_ca59_d596_7250_de9d1939227f a0b28eb3_d4e0_bb21_6a83_ba005c9793f4["rich"] f256b1e3_d2b3_ac5c_1d2c_4432a530febc --> a0b28eb3_d4e0_bb21_6a83_ba005c9793f4 d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"] f256b1e3_d2b3_ac5c_1d2c_4432a530febc --> d10c5377_2939_0f0b_cc44_8759393f2853 style f256b1e3_d2b3_ac5c_1d2c_4432a530febc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import json
from typing_extensions import Literal
import rich
from anthropic import Anthropic, beta_tool
client = Anthropic()
@beta_tool
def get_weather(location: str, units: Literal["c", "f"]) -> str:
"""Lookup the weather for a given city in either celsius or fahrenheit
Args:
location: The city and state, e.g. San Francisco, CA
units: Unit for the output, either 'c' for celsius or 'f' for fahrenheit
Returns:
A dictionary containing the location, temperature, and weather condition.
"""
# Simulate a weather API call
print(f"Fetching weather for {location} in {units}")
# Here you would typically make an API call to a weather service
# For demonstration, we return a mock response
if units == "c":
return json.dumps(
{
"location": location,
"temperature": "20°C",
"condition": "Sunny",
}
)
else:
return json.dumps(
{
"location": location,
"temperature": "68°F",
"condition": "Sunny",
}
)
def main() -> None:
runner = client.beta.messages.tool_runner(
max_tokens=1024,
model="claude-3-5-sonnet-latest",
# alternatively, you can use `tools=[anthropic.beta_tool(get_weather)]`
tools=[get_weather],
messages=[{"role": "user", "content": "What is the weather in SF?"}],
)
for message in runner:
rich.print(message)
main()
Domain
Subdomains
Functions
Dependencies
- anthropic
- json
- rich
- typing_extensions
Source
Frequently Asked Questions
What does tools_runner.py do?
tools_runner.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in tools_runner.py?
tools_runner.py defines 2 function(s): get_weather, main.
What does tools_runner.py depend on?
tools_runner.py imports 4 module(s): anthropic, json, rich, typing_extensions.
Where is tools_runner.py in the architecture?
tools_runner.py is located at examples/tools_runner.py (domain: AnthropicClient, subdomain: SyncAPI, directory: examples).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free