Instantly turn your Python functions into structured, AI-callable tools.
Project description
toolsmith
Toolsmith turns your Python functions into structured, AI-callable tools, using type hints and docstrings. Integrates with any LLM provider that is compatible with the OpenAI API.
- Very easy to use: Just write normal Python functions with typehints.
- Pydantic support: Pydantic types get automatically serialized and deserialized.
- Unopinionated: Toolsmith gets out of the way in terms of how you want to wire up the LLM loop.
- Fast: Highly performant based on Pydantic's speed.
Installation
$ pip install toolsmith
Usage
Simply define any functions you may have normally:
def create_user(name: str, age: int) -> str:
"""Saves a user to the DB"""
return f"Created user {name}, age {age}"
def search_users(query: str, regex: bool) -> str:
return "Found some users"
Put it all together and call the OpenAI API:
import openai
import toolsmith
toolbox = toolsmith.create([create_user, search_users])
client = openai.OpenAI()
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Make a 33 year old user called Alice"}]
tools=toolbox.get_schema(),
)
invocations = toolbox.parse_invocations(response.choices[0].message.tool_calls)
results = toolbox.execute_function_calls(invocations)
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 toolsmith-0.1.1a0.tar.gz.
File metadata
- Download URL: toolsmith-0.1.1a0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.10.9 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a7e1d7c021633f273a43e95e00cd369ec5c24cbc6f5b882b13ab68fefb26dd8
|
|
| MD5 |
dd0c095b7e10d1b84d227fcbfc373d57
|
|
| BLAKE2b-256 |
208ac9e5a4ae39f18ba757eea47a03f1fd1fa8394fa0f9bbd552841dd30be5e9
|
File details
Details for the file toolsmith-0.1.1a0-py3-none-any.whl.
File metadata
- Download URL: toolsmith-0.1.1a0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.10.9 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c3c561dfdce110a55e083f9f85fed0f5857fbd40e7b9853a66575d1d1bdd96c
|
|
| MD5 |
05c04ffa1b3a6218862fd6926264b2c0
|
|
| BLAKE2b-256 |
d47f7dd7c26266a49c6c2d4dafe8bbb616df30c614c5974f58cc21a5c7e1c2ee
|