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-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-tools
Usage
import anthropic
import claude_tools
@claude_tools.tool
def add_numbers(req: claude_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_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_tools.tools()
)
for block in message.content:
match block.type:
case 'text':
...
case 'tool_use':
result = await claude_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.1.0.tar.gz
(14.4 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.1.0.tar.gz.
File metadata
- Download URL: claude_llm_tools-0.1.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b11aac279441af09f144d656025743ce2e2d27dbff3d8a0d278de0dbde77667
|
|
| MD5 |
cf2931001c073239be89de5218e0d7ce
|
|
| BLAKE2b-256 |
9d19ca4f20475158e3f7e489ebb121bd996f475c3907fedfbb4190662bf42b14
|
File details
Details for the file claude_llm_tools-0.1.0-py3-none-any.whl.
File metadata
- Download URL: claude_llm_tools-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79e8940e53c661386a400b4a3064788f44695f51e52e37842c0255ecbbe71cf1
|
|
| MD5 |
5dec1992bf6e1a38cc2936366fff10ed
|
|
| BLAKE2b-256 |
72c41c41e40834ae968856cb889744088b07ba4a73813dcbf92d2235915ce39e
|