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.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  56b98680_b251_3190_f82a_988d593f3d5c["get_weather()"]
  6f10ce67_ed2e_12f9_5e2a_8fd297fb064e["tools_runner.py"]
  56b98680_b251_3190_f82a_988d593f3d5c -->|defined in| 6f10ce67_ed2e_12f9_5e2a_8fd297fb064e
  style 56b98680_b251_3190_f82a_988d593f3d5c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/tools_runner.py lines 12–41

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

Domain

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.py.
Where is get_weather() defined?
get_weather() is defined in examples/tools_runner.py at line 12.

Analyze Your Own Codebase

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

Try Supermodel Free