Home / Function/ get_weather() — anthropic-sdk-python Function Reference

get_weather() — anthropic-sdk-python Function Reference

Architecture documentation for the get_weather() function in tools_runner_search_tool.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  e12dd2b7_4056_86e4_8175_d18acf9ac380["get_weather()"]
  fb1a4163_0002_aa33_791c_d193be58f7a1["tools_runner_search_tool.py"]
  e12dd2b7_4056_86e4_8175_d18acf9ac380 -->|defined in| fb1a4163_0002_aa33_791c_d193be58f7a1
  style e12dd2b7_4056_86e4_8175_d18acf9ac380 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/tools_runner_search_tool.py lines 15–44

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",
            }
        )

Subdomains

Frequently Asked Questions

What does get_weather() do?
get_weather() is a function in the anthropic-sdk-python codebase, defined in examples/tools_runner_search_tool.py.
Where is get_weather() defined?
get_weather() is defined in examples/tools_runner_search_tool.py at line 15.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free