Home / File/ tools.py — anthropic-sdk-python Source File

tools.py — anthropic-sdk-python Source File

Architecture documentation for tools.py, a python file in the anthropic-sdk-python codebase. 2 imports, 0 dependents.

File python 2 imports

Entity Profile

Dependency Diagram

graph LR
  a991ad4f_0173_c6d0_1dd3_818fe209005d["tools.py"]
  d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"]
  a991ad4f_0173_c6d0_1dd3_818fe209005d --> d10c5377_2939_0f0b_cc44_8759393f2853
  96be2c65_41eb_5f34_98ec_2f14a3932c96["anthropic.types"]
  a991ad4f_0173_c6d0_1dd3_818fe209005d --> 96be2c65_41eb_5f34_98ec_2f14a3932c96
  style a991ad4f_0173_c6d0_1dd3_818fe209005d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

from anthropic import Anthropic
from anthropic.types import ToolParam, MessageParam

client = Anthropic()

user_message: MessageParam = {
    "role": "user",
    "content": "What is the weather in SF?",
}
tools: list[ToolParam] = [
    {
        "name": "get_weather",
        "description": "Get the weather for a specific location",
        "input_schema": {
            "type": "object",
            "properties": {"location": {"type": "string"}},
        },
    }
]

message = client.messages.create(
    model="claude-sonnet-4-5-20250929",
    max_tokens=1024,
    messages=[user_message],
    tools=tools,
)
print(f"Initial response: {message.model_dump_json(indent=2)}")

assert message.stop_reason == "tool_use"

tool = next(c for c in message.content if c.type == "tool_use")
response = client.messages.create(
    model="claude-sonnet-4-5-20250929",
    max_tokens=1024,
    messages=[
        user_message,
        {"role": message.role, "content": message.content},
        {
            "role": "user",
            "content": [
                {
                    "type": "tool_result",
                    "tool_use_id": tool.id,
                    "content": [{"type": "text", "text": "The weather is 73f"}],
                }
            ],
        },
    ],
    tools=tools,
)
print(f"\nFinal response: {response.model_dump_json(indent=2)}")

Dependencies

  • anthropic
  • anthropic.types

Frequently Asked Questions

What does tools.py do?
tools.py is a source file in the anthropic-sdk-python codebase, written in python.
What does tools.py depend on?
tools.py imports 2 module(s): anthropic, anthropic.types.
Where is tools.py in the architecture?
tools.py is located at examples/tools.py (directory: examples).

Analyze Your Own Codebase

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

Try Supermodel Free