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
@claude_llm_tools.tool(
name='multiply_numbers',
description='Multiply two numbers together and return the product.'
)
def multiply(req: claude_llm_tools.Request, x: int, y: int) -> int:
"""This docstring will be overridden by the description parameter above."""
print(req.tool_use.id)
return x * y
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.3.0.tar.gz
(12.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_llm_tools-0.3.0.tar.gz.
File metadata
- Download URL: claude_llm_tools-0.3.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60bfd6c20793103aa6b0dfb477b3105a541bad2dec63798bd8b3981537c29f07
|
|
| MD5 |
2bf475a4a7f43dc716c256de37439d8c
|
|
| BLAKE2b-256 |
e49982ffd4546dc8d86080ee7b8f26371b2bfd4e351164fd6f5e6072a6adf66f
|
File details
Details for the file claude_llm_tools-0.3.0-py3-none-any.whl.
File metadata
- Download URL: claude_llm_tools-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c2297002eff63c4ec28ab28c111d81c5a64f9a830502adbc729610c17191586
|
|
| MD5 |
5f96011fff0a708c38e9069e516b0fd1
|
|
| BLAKE2b-256 |
0a937e0b47988dc54096733cc1780c806604ae3044ae37356bb090e63810e124
|