llmtk (LLM Toolkit)
Stop writing JSON schemas for your AI functions. Let Python types do it for you. ⚡️
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:
# 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:
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
pip install llmtk
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!
Metadata
Release files for llmtk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llmtk-0.1.0.tar.gz | 6.6 kB | Without provenance | Details for llmtk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llmtk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for llmtk-0.1.0-py3-none-any.whl |
Total release size: 12.4 kB
Release files / llmtk-0.1.0.tar.gz
| Download URL | llmtk-0.1.0.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9bd0d476a9c8bc77a793afb59f61a7d4d424350277abe17d7e31f0e8cefa5a0e
|
|
BLAKE2b-256 checksum How to use checksums |
6f34d93d5a08f287dc85f346b453849ac7b22fce415554e81c0be101497dbdc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / llmtk-0.1.0-py3-none-any.whl
| Download URL | llmtk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e6409984f0d22b0e3c22a02159853ebdc04c8b387626c658dbcc07466fca36a
|
|
BLAKE2b-256 checksum How to use checksums |
1f08e7213a179989f79f6385a2c9a9c7f1a07bcb17b9f9d25a96b634da225e4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Security for llmtk 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.