Metadata-Version: 2.2
Name: llmtk
Version: 0.1.0
Summary: Type-safe function registration and validation for LLM function calls
Home-page: https://github.com/arcifylabs/llmtk
Author: Ritik Sahni
Author-email: ritik@arcifylabs.com
Project-URL: Bug Tracker, https://github.com/arcifylabs/llmtk/issues
Project-URL: Documentation, https://github.com/arcifylabs/llmtk#readme
Project-URL: Source Code, https://github.com/arcifylabs/llmtk
Keywords: llm,openai,function-calling,type-safety,validation,pydantic
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: black>=22.0.0; extra == "dev"
Requires-Dist: isort>=5.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: types-setuptools>=75.0.0; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# llmtk (LLM Toolkit)

> Stop writing JSON schemas for your AI functions. Let Python types do it for you. ⚡️

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)

## Features

- 🎯 **Zero Schema Maintenance**: Your Python types become your OpenAI schemas
- ✨ **Type Safety**: Catch invalid AI responses before they break your code
- 📝 **Rich Types**: Support for Pydantic models, lists, and custom types
- 🚀 **Quick Setup**: One decorator is all you need

## Without llmtk, you write this:


```python
# Define your function
def get_weather(city: str) -> str:
    return f"Weather in {city}: Sunny"

# Manually maintain OpenAI function schema
weather_schema = {
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get weather information for a city",
        "parameters": {
            "type": "object",
            "properties": {
                "city": {
                    "type": "string",
                    "description": "Name of the city"
                }
            },
            "required": ["city"]
        }
    }
}

# Hope the schema stays in sync with your function
tools = [weather_schema]
```

## With llmtk, just write this:

```python
from llmtk import register_function, get_openai_tools

@register_function
def get_weather(city: str) -> str:
    """Get weather information for a city"""
    return f"Weather in {city}: Sunny"

# Schema automatically generated from your Python types
tools = get_openai_tools()
```

## Quick Start

```bash
pip install llmtk
```

```python
from llmtk import register_function, call_function, get_openai_tools

@register_function
def calculate_price(quantity: int, unit_price: float) -> float:
    """Calculate total price for items"""
    return quantity * unit_price

# Get schema for OpenAI
tools = get_openai_tools()

# Use with OpenAI
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Calculate price for 5 items at $10 each"}],
    tools=tools,
    tool_choice="auto"
)

# Safe function execution with validation
result = call_function(
    response.choices[0].message.tool_calls[0].function.name,
    response.choices[0].message.tool_calls[0].function.arguments
)

if isinstance(result, tuple):
    print(f"Validation error: {result[0]}")
else:
    print(f"Total: ${result:.2f}")  # Total: $50.00
```
## License

MIT License - feel free to use in your projects!
