A lightweight tool registry for function metadata management
Project description
Agent Tooling
A lightweight Python package for registering and managing function metadata and references.
Installation
pip install agent_tooling
Usage
from agent_tooling import tool, get_tool_schemas, get_tool_function
@tool
def add_numbers(a: int, b: int) -> int:
"""Simple function to add two numbers."""
return a + b
# Get registered tool metadata
tool_schemas = get_tool_schemas()
print(tool_schemas)
# Get function reference by name
func = get_tool_function('add_numbers')
result = func(5, 3) # Returns 8
Example Output
[{
'name': 'add_numbers',
'description': 'Simple function to add two numbers.',
'parameters': {
'type': 'object',
'properties': {
'a': {'type': 'integer'},
'b': {'type': 'integer'}
},
'required': ['a', 'b']
},
'return_type': 'integer'
}]
Features
- Easy function metadata registration
- Automatic introspection of function signatures
- Singleton tool registry
- JSON-schema compatible parameter definitions
- Function reference storage and retrieval
- Compatible with AI tools frameworks
API Reference
@tool
Decorator to register a function as a tool, capturing its metadata and storing its reference.
get_tool_schemas()
Returns a list of metadata schemas for all registered tools.
get_tool_function(name)
Returns the function reference for a registered tool by name.
get_registered_tools() (Legacy)
Alias for get_tool_schemas() maintained for backward compatibility.
Example with AI Tool Integration
from agent_tooling import tool, get_tool_schemas, get_tool_function
from openai import OpenAI
import json
@tool
def get_weather(location: str, unit: str = "celsius") -> str:
"""Get the current weather for a location."""
# Implementation omitted
return f"The weather in {location} is sunny and 25°{unit[0].upper()}"
# Get tool schemas for AI model
tools = get_tool_schemas()
# Create AI client
client = OpenAI()
# Send request to AI with tools
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "What's the weather in Paris?"}],
tools=tools,
tool_choice="auto",
)
# Process tool calls
if response.choices[0].message.tool_calls:
for tool_call in response.choices[0].message.tool_calls:
name = tool_call.function.name
args = json.loads(tool_call.function.arguments)
# Get and call the function
function_to_call = get_tool_function(name)
result = function_to_call(**args)
print(result) # "The weather in Paris is sunny and 25°C"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 agent_tooling-0.2.6.tar.gz.
File metadata
- Download URL: agent_tooling-0.2.6.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d87345303e345d39d16908ce9b6884eabb4507308fd9e7249367d48511e71a3
|
|
| MD5 |
340ca96dd2d74df5e3fbb6b3deb3a8f1
|
|
| BLAKE2b-256 |
0668272417f9a074d4acbde3f757602dc3d9a3e7a11809f69acb296bbaee1f4e
|
File details
Details for the file agent_tooling-0.2.6-py3-none-any.whl.
File metadata
- Download URL: agent_tooling-0.2.6-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a20b4fd09d4bd60c47870ca3feea52def064eda7609304406af37d292533a91e
|
|
| MD5 |
9e7bd190ea3ff611596c01fdda177427
|
|
| BLAKE2b-256 |
ff3e79e1e7a0987e929359ee973d13198e1f405500b693b22c511d30087318a9
|