Skip to main content

A library for auto-generating JSON Schema and dispatching tool calls in applications that use the Anthropic API to interact with Claude.

Project description

Claude LLM Tools

A library for auto-generating JSON Schema and dispatching tool calls in applications that use the Anthropic API to interact with Claude.

Installation

pip install claude-llm-tools

Usage

import anthropic
import claude_llm_tools


@claude_llm_tools.tool
def add_numbers(req: claude_llm_tools.Request, a: int, b: int) -> int:
    """
    Add two numbers together and return the result.

    Args:
        a: The first number
        b: The second number

    Returns:
        The sum of a and b
    """
    print(req.tool_use.id)
    return a + b


client = anthropic.Anthropic()

# You can implement the Anthropic text editor contract
claude_llm_tools.add_tool(..., tool_type='text_editor_20250124')

message = client.messages.create(
    model="claude-3-7-sonnet-20250219",
    max_tokens=1000,
    temperature=1,
    system="You are a world-class poet. Respond only with short poems about math.",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Why is the ocean salty?"
                }
            ]
        }
    ],
    tools=claude_llm_tools.tools()
)

for block in message.content:
    match block.type:
        case 'text':
            ...
        case 'tool_use':
            result = await claude_llm_tools.dispatch(block)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_llm_tools-0.2.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_llm_tools-0.2.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file claude_llm_tools-0.2.0.tar.gz.

File metadata

  • Download URL: claude_llm_tools-0.2.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for claude_llm_tools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 883b13934fcdbb12b613b800a266eb2ae819085411a4a93d7bc14d82b0168ed9
MD5 22ff28f9d9a343029582775b3b32db8a
BLAKE2b-256 070cd6ff8064bef073069f6ee9d83179d5e26c9a3d674a1c8097035bdaaa4aef

See more details on using hashes here.

File details

Details for the file claude_llm_tools-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_llm_tools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 996d624b4599fc2a640e674466bd5f604b7a6e0c201a3731e931c10366ddd09b
MD5 24be4082b6bc66bc8db637f034f636e1
BLAKE2b-256 331378756a35ea9c093a2ef928374f97eed4837919de2272cbfa27e6cee7aa32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page