ai-tool-registry


Nameai-tool-registry JSON
Version 0.5.2 PyPI version JSON
download
home_pageNone
SummaryAdvanced tool registration system for Anthropic Claude integration with automatic schema generation and validation
upload_time2025-07-22 17:03:32
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseMIT
keywords anthropic api claude schema tools validation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Universal Tool Registry Module

Advanced tool registration system for multiple AI providers with automatic schema generation, validation, and error handling. Supports **Anthropic Claude**, **OpenAI**, **Mistral AI**, **AWS Bedrock**, and **Google Gemini**.

## Features

- **Multi-provider support** - Works with all major AI providers
- **Automatic JSON schema generation** from function signatures
- **Pydantic model integration** and validation
- **Parameter filtering** for internal/context parameters
- **Unified interface** across different AI providers
- **Comprehensive error handling** and logging
- **Type safety** with full type hints
- **Optional dependencies** - Install only what you need

## Installation

### Basic Installation

```bash
# Using UV (recommended)
uv add ai-tool-registry

# Using pip
pip install ai-tool-registry
```

### Provider-Specific Installation

```bash
# For Anthropic Claude
uv add ai-tool-registry[anthropic]

# For OpenAI
uv add ai-tool-registry[openai]

# For Mistral AI 
uv add ai-tool-registry[mistral]

# For AWS Bedrock
uv add ai-tool-registry[bedrock]

# For Google Gemini
uv add ai-tool-registry[gemini]

# Install all providers
uv add ai-tool-registry[all]
```

## Quick Start

```python
from tool_registry_module import tool, build_registry_openai, build_registry_anthropic
from pydantic import BaseModel


class UserData(BaseModel):
    name: str
    age: int


@tool(description="Process user information")
def process_user(input: UserData, context: str = "default") -> UserData:
    return input


# Build registries for different providers
openai_registry = build_registry_openai([process_user])
anthropic_registry = build_registry_anthropic([process_user])

# Use with respective APIs
openai_tools = [entry["representation"] for entry in openai_registry.values()]
anthropic_tools = [entry["representation"] for entry in anthropic_registry.values()]
```

## Multi-Provider Examples

### OpenAI Function Calling

```python
from tool_registry_module import tool, build_registry_openai
import openai

@tool(description="Get weather information")
def get_weather(location: str, unit: str = "celsius") -> str:
    return f"Weather in {location}: 22°{unit[0].upper()}"

# Build OpenAI registry
registry = build_registry_openai([get_weather])
tools = [entry["representation"] for entry in registry.values()]

# Use with OpenAI
client = openai.OpenAI()
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "What's the weather in Paris?"}],
    tools=tools
)
```

### Anthropic Claude

```python
from tool_registry_module import tool, build_registry_anthropic
import anthropic

registry = build_registry_anthropic([get_weather])
tools = [entry["representation"] for entry in registry.values()]

# Use with Anthropic
client = anthropic.Anthropic()
response = client.messages.create(
    model="claude-3-sonnet-20240229",
    max_tokens=1000,
    messages=[{"role": "user", "content": "What's the weather in Paris?"}],
    tools=tools
)
```

### AWS Bedrock

```python
from tool_registry_module import tool, build_registry_bedrock
import boto3

registry = build_registry_bedrock([get_weather])
tools = [entry["representation"] for entry in registry.values()]

# Use with Bedrock
client = boto3.client("bedrock-runtime")
# Use tools in your Bedrock converse API calls
```

### Google Gemini

```python
from tool_registry_module import tool, build_registry_gemini
import google.generativeai as genai

registry = build_registry_gemini([get_weather])
tools = [entry["representation"] for entry in registry.values()]

# Use with Gemini
model = genai.GenerativeModel('gemini-pro')
# Use tools in your Gemini function calling
```

### Mistral AI

```python
from tool_registry_module import tool, build_registry_mistral
from mistralai.client import MistralClient

registry = build_registry_mistral([get_weather])
tools = [entry["representation"] for entry in registry.values()]

# Use with Mistral
client = MistralClient()
# Use tools in your Mistral function calling
```

## Advanced Usage

### Parameter Filtering

Exclude internal parameters from the schema:

```python
@tool(
    description="Calculate area with debug output",
    ignore_in_schema=["debug_mode", "context"]
)
def calculate_area(length: float, width: float, debug_mode: bool = False, context: str = "calc") -> float:
    if debug_mode:
        print(f"Calculating area for {length} x {width}")
    return length * width
```

### Cache Control (Anthropic)

Add cache control for better performance with Anthropic:

```python
@tool(
    description="Expensive computation",
    cache_control={"type": "ephemeral"}
)
def expensive_function(data: str) -> str:
    # Expensive computation here
    return processed_data
```

#### Registry Utilities

```python
from tool_registry_module import get_tool_info, validate_registry

# Get information about a specific tool
info = get_tool_info(registry, "process_user")
print(info["description"])

# Validate registry structure
is_valid = validate_registry(registry)
```

### Tool Use Handling

The registry is a dictionary that enables dynamic function calling for AI tool responses:

```python
from tool_registry_module import tool, build_registry_anthropic

@tool(description="Add two numbers")
def add_numbers(a: int, b: int) -> int:
    return a + b

@tool(description="Get weather info")
def get_weather(city: str, units: str = "celsius") -> str:
    return f"Weather in {city}: 22°{units[0].upper()}"

# Build registry
registry = build_registry_anthropic([add_numbers, get_weather])

# Handle tool use responses dynamically
def handle_tool_calls(tool_calls, registry):
    results = []
    for tool_call in tool_calls:
        tool_name = tool_call.name
        tool_args = tool_call.input
        
        if tool_name in registry:
            try:
                # Get function from registry and execute
                tool_func = registry[tool_name]["tool"]
                result = tool_func(**tool_args)
                results.append({
                    "tool_use_id": tool_call.id,
                    "content": str(result)
                })
            except Exception as e:
                results.append({
                    "tool_use_id": tool_call.id,
                    "error": f"Error: {e}"
                })
        else:
            results.append({
                "tool_use_id": tool_call.id,
                "error": f"Tool '{tool_name}' not found"
            })
    
    return results

# Registry structure: {tool_name: {"tool": callable, "representation": provider_format}}
# Use registry[tool_name]["tool"] for dynamic function calling
```

## Supported Providers

| Provider | Function | Format |
|----------|----------|---------|
| **Anthropic Claude** | `build_registry_anthropic()` | Claude ToolParam |
| **OpenAI** | `build_registry_openai()` | OpenAI Function Call |
| **Mistral AI** | `build_registry_mistral()` | Mistral Function Call |
| **AWS Bedrock** | `build_registry_bedrock()` | Bedrock ToolSpec |
| **Google Gemini** | `build_registry_gemini()` | Gemini FunctionDeclaration |

## Requirements

- **Python 3.12+**
- **pydantic >= 2.0.0** (required)

### Optional Provider Dependencies

- **anthropic >= 0.52.2** (for Anthropic Claude)
- **openai >= 1.0.0** (for OpenAI)
- **mistralai >= 0.4.0** (for Mistral AI)  
- **boto3 >= 1.34.0** (for AWS Bedrock)
- **google-generativeai >= 0.3.0** (for Google Gemini)

## Migration from v2.x

The old `build_registry_anthropic_tool_registry()` function is still available for backward compatibility but deprecated. Use `build_registry_anthropic()` instead.

## License

MIT License

## Development

### Setup

```bash
# Clone and install with dev dependencies
git clone https://github.com/kazmer97/ai-tool-registry.git
cd ai-tool-registry
uv sync --extra dev

# Run linting
uv run ruff check .
uv run ruff format .
```

### Testing

```bash
# Run tests (when available)
uv run pytest

# Type checking
uv run mypy tool_registry_module/
```

## Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Run linting: `uv run ruff check . && uv run ruff format .`
4. Commit changes (`git commit -m 'Add amazing feature'`)
5. Push to branch (`git push origin feature/amazing-feature`)
6. Open a Pull Request
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ai-tool-registry",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "anthropic, api, claude, schema, tools, validation",
    "author": null,
    "author_email": "\"Kazmer, Nagy-Betegh\" <kazmer.nb@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d1/12/63df8a4678130326d7e1afd265f570b2c8537963317debed88f0a622c82e/ai_tool_registry-0.5.2.tar.gz",
    "platform": null,
    "description": "# Universal Tool Registry Module\n\nAdvanced tool registration system for multiple AI providers with automatic schema generation, validation, and error handling. Supports **Anthropic Claude**, **OpenAI**, **Mistral AI**, **AWS Bedrock**, and **Google Gemini**.\n\n## Features\n\n- **Multi-provider support** - Works with all major AI providers\n- **Automatic JSON schema generation** from function signatures\n- **Pydantic model integration** and validation\n- **Parameter filtering** for internal/context parameters\n- **Unified interface** across different AI providers\n- **Comprehensive error handling** and logging\n- **Type safety** with full type hints\n- **Optional dependencies** - Install only what you need\n\n## Installation\n\n### Basic Installation\n\n```bash\n# Using UV (recommended)\nuv add ai-tool-registry\n\n# Using pip\npip install ai-tool-registry\n```\n\n### Provider-Specific Installation\n\n```bash\n# For Anthropic Claude\nuv add ai-tool-registry[anthropic]\n\n# For OpenAI\nuv add ai-tool-registry[openai]\n\n# For Mistral AI \nuv add ai-tool-registry[mistral]\n\n# For AWS Bedrock\nuv add ai-tool-registry[bedrock]\n\n# For Google Gemini\nuv add ai-tool-registry[gemini]\n\n# Install all providers\nuv add ai-tool-registry[all]\n```\n\n## Quick Start\n\n```python\nfrom tool_registry_module import tool, build_registry_openai, build_registry_anthropic\nfrom pydantic import BaseModel\n\n\nclass UserData(BaseModel):\n    name: str\n    age: int\n\n\n@tool(description=\"Process user information\")\ndef process_user(input: UserData, context: str = \"default\") -> UserData:\n    return input\n\n\n# Build registries for different providers\nopenai_registry = build_registry_openai([process_user])\nanthropic_registry = build_registry_anthropic([process_user])\n\n# Use with respective APIs\nopenai_tools = [entry[\"representation\"] for entry in openai_registry.values()]\nanthropic_tools = [entry[\"representation\"] for entry in anthropic_registry.values()]\n```\n\n## Multi-Provider Examples\n\n### OpenAI Function Calling\n\n```python\nfrom tool_registry_module import tool, build_registry_openai\nimport openai\n\n@tool(description=\"Get weather information\")\ndef get_weather(location: str, unit: str = \"celsius\") -> str:\n    return f\"Weather in {location}: 22\u00b0{unit[0].upper()}\"\n\n# Build OpenAI registry\nregistry = build_registry_openai([get_weather])\ntools = [entry[\"representation\"] for entry in registry.values()]\n\n# Use with OpenAI\nclient = openai.OpenAI()\nresponse = client.chat.completions.create(\n    model=\"gpt-4\",\n    messages=[{\"role\": \"user\", \"content\": \"What's the weather in Paris?\"}],\n    tools=tools\n)\n```\n\n### Anthropic Claude\n\n```python\nfrom tool_registry_module import tool, build_registry_anthropic\nimport anthropic\n\nregistry = build_registry_anthropic([get_weather])\ntools = [entry[\"representation\"] for entry in registry.values()]\n\n# Use with Anthropic\nclient = anthropic.Anthropic()\nresponse = client.messages.create(\n    model=\"claude-3-sonnet-20240229\",\n    max_tokens=1000,\n    messages=[{\"role\": \"user\", \"content\": \"What's the weather in Paris?\"}],\n    tools=tools\n)\n```\n\n### AWS Bedrock\n\n```python\nfrom tool_registry_module import tool, build_registry_bedrock\nimport boto3\n\nregistry = build_registry_bedrock([get_weather])\ntools = [entry[\"representation\"] for entry in registry.values()]\n\n# Use with Bedrock\nclient = boto3.client(\"bedrock-runtime\")\n# Use tools in your Bedrock converse API calls\n```\n\n### Google Gemini\n\n```python\nfrom tool_registry_module import tool, build_registry_gemini\nimport google.generativeai as genai\n\nregistry = build_registry_gemini([get_weather])\ntools = [entry[\"representation\"] for entry in registry.values()]\n\n# Use with Gemini\nmodel = genai.GenerativeModel('gemini-pro')\n# Use tools in your Gemini function calling\n```\n\n### Mistral AI\n\n```python\nfrom tool_registry_module import tool, build_registry_mistral\nfrom mistralai.client import MistralClient\n\nregistry = build_registry_mistral([get_weather])\ntools = [entry[\"representation\"] for entry in registry.values()]\n\n# Use with Mistral\nclient = MistralClient()\n# Use tools in your Mistral function calling\n```\n\n## Advanced Usage\n\n### Parameter Filtering\n\nExclude internal parameters from the schema:\n\n```python\n@tool(\n    description=\"Calculate area with debug output\",\n    ignore_in_schema=[\"debug_mode\", \"context\"]\n)\ndef calculate_area(length: float, width: float, debug_mode: bool = False, context: str = \"calc\") -> float:\n    if debug_mode:\n        print(f\"Calculating area for {length} x {width}\")\n    return length * width\n```\n\n### Cache Control (Anthropic)\n\nAdd cache control for better performance with Anthropic:\n\n```python\n@tool(\n    description=\"Expensive computation\",\n    cache_control={\"type\": \"ephemeral\"}\n)\ndef expensive_function(data: str) -> str:\n    # Expensive computation here\n    return processed_data\n```\n\n#### Registry Utilities\n\n```python\nfrom tool_registry_module import get_tool_info, validate_registry\n\n# Get information about a specific tool\ninfo = get_tool_info(registry, \"process_user\")\nprint(info[\"description\"])\n\n# Validate registry structure\nis_valid = validate_registry(registry)\n```\n\n### Tool Use Handling\n\nThe registry is a dictionary that enables dynamic function calling for AI tool responses:\n\n```python\nfrom tool_registry_module import tool, build_registry_anthropic\n\n@tool(description=\"Add two numbers\")\ndef add_numbers(a: int, b: int) -> int:\n    return a + b\n\n@tool(description=\"Get weather info\")\ndef get_weather(city: str, units: str = \"celsius\") -> str:\n    return f\"Weather in {city}: 22\u00b0{units[0].upper()}\"\n\n# Build registry\nregistry = build_registry_anthropic([add_numbers, get_weather])\n\n# Handle tool use responses dynamically\ndef handle_tool_calls(tool_calls, registry):\n    results = []\n    for tool_call in tool_calls:\n        tool_name = tool_call.name\n        tool_args = tool_call.input\n        \n        if tool_name in registry:\n            try:\n                # Get function from registry and execute\n                tool_func = registry[tool_name][\"tool\"]\n                result = tool_func(**tool_args)\n                results.append({\n                    \"tool_use_id\": tool_call.id,\n                    \"content\": str(result)\n                })\n            except Exception as e:\n                results.append({\n                    \"tool_use_id\": tool_call.id,\n                    \"error\": f\"Error: {e}\"\n                })\n        else:\n            results.append({\n                \"tool_use_id\": tool_call.id,\n                \"error\": f\"Tool '{tool_name}' not found\"\n            })\n    \n    return results\n\n# Registry structure: {tool_name: {\"tool\": callable, \"representation\": provider_format}}\n# Use registry[tool_name][\"tool\"] for dynamic function calling\n```\n\n## Supported Providers\n\n| Provider | Function | Format |\n|----------|----------|---------|\n| **Anthropic Claude** | `build_registry_anthropic()` | Claude ToolParam |\n| **OpenAI** | `build_registry_openai()` | OpenAI Function Call |\n| **Mistral AI** | `build_registry_mistral()` | Mistral Function Call |\n| **AWS Bedrock** | `build_registry_bedrock()` | Bedrock ToolSpec |\n| **Google Gemini** | `build_registry_gemini()` | Gemini FunctionDeclaration |\n\n## Requirements\n\n- **Python 3.12+**\n- **pydantic >= 2.0.0** (required)\n\n### Optional Provider Dependencies\n\n- **anthropic >= 0.52.2** (for Anthropic Claude)\n- **openai >= 1.0.0** (for OpenAI)\n- **mistralai >= 0.4.0** (for Mistral AI)  \n- **boto3 >= 1.34.0** (for AWS Bedrock)\n- **google-generativeai >= 0.3.0** (for Google Gemini)\n\n## Migration from v2.x\n\nThe old `build_registry_anthropic_tool_registry()` function is still available for backward compatibility but deprecated. Use `build_registry_anthropic()` instead.\n\n## License\n\nMIT License\n\n## Development\n\n### Setup\n\n```bash\n# Clone and install with dev dependencies\ngit clone https://github.com/kazmer97/ai-tool-registry.git\ncd ai-tool-registry\nuv sync --extra dev\n\n# Run linting\nuv run ruff check .\nuv run ruff format .\n```\n\n### Testing\n\n```bash\n# Run tests (when available)\nuv run pytest\n\n# Type checking\nuv run mypy tool_registry_module/\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Run linting: `uv run ruff check . && uv run ruff format .`\n4. Commit changes (`git commit -m 'Add amazing feature'`)\n5. Push to branch (`git push origin feature/amazing-feature`)\n6. Open a Pull Request",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Advanced tool registration system for Anthropic Claude integration with automatic schema generation and validation",
    "version": "0.5.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/kazmer97/ai-tool-registry/issues",
        "Documentation": "https://github.com/kazmer97/ai-tool-registry#readme",
        "Homepage": "https://github.com/kazmer97/ai-tool-registry",
        "Repository": "https://github.com/kazmer97/ai-tool-registry"
    },
    "split_keywords": [
        "anthropic",
        " api",
        " claude",
        " schema",
        " tools",
        " validation"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "255ff6cfde1cc143ead847c823ef085d61da3107b89ef365973c0ca7b68149f8",
                "md5": "41571ed89f71e36992680b778f9398f9",
                "sha256": "bc14fd8cfaf5ab5c301f1523d6a0be2d54a87d3ec227a0335cc0c7f037ee014d"
            },
            "downloads": -1,
            "filename": "ai_tool_registry-0.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "41571ed89f71e36992680b778f9398f9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 13794,
            "upload_time": "2025-07-22T17:03:31",
            "upload_time_iso_8601": "2025-07-22T17:03:31.331848Z",
            "url": "https://files.pythonhosted.org/packages/25/5f/f6cfde1cc143ead847c823ef085d61da3107b89ef365973c0ca7b68149f8/ai_tool_registry-0.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d11263df8a4678130326d7e1afd265f570b2c8537963317debed88f0a622c82e",
                "md5": "3bb1e675f4ed0107b3e4304c3fee2ad3",
                "sha256": "0bc3f750bcbe8553699a8cc5d935c350fb9b3f5e5556c9e6daa396cec5ce43d4"
            },
            "downloads": -1,
            "filename": "ai_tool_registry-0.5.2.tar.gz",
            "has_sig": false,
            "md5_digest": "3bb1e675f4ed0107b3e4304c3fee2ad3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 60444,
            "upload_time": "2025-07-22T17:03:32",
            "upload_time_iso_8601": "2025-07-22T17:03:32.771720Z",
            "url": "https://files.pythonhosted.org/packages/d1/12/63df8a4678130326d7e1afd265f570b2c8537963317debed88f0a622c82e/ai_tool_registry-0.5.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-22 17:03:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kazmer97",
    "github_project": "ai-tool-registry",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ai-tool-registry"
}
        
Elapsed time: 1.79759s