Skip to main content

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.
  • Async support: Built-in support for async functions with parallel execution of multiple tool calls.

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
from toolsmith import AsyncToolbox

toolbox = AsyncToolbox.create([create_user, search_users])

client = openai.AsyncOpenAI()
response = await client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Make a 33 year old user called Alice"}]
    tools=toolbox.get_schema(),  # toolsmith handles the schema
)

# toolsmith will automatically call your functions here
results = await toolbox.execute_tool_calls(response.choices[0].message.tool_calls)

Learn more

https://dougli.github.io/toolsmith/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toolsmith-0.2.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toolsmith-0.2.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file toolsmith-0.2.1.tar.gz.

File metadata

  • Download URL: toolsmith-0.2.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.2 Darwin/24.6.0

File hashes

Hashes for toolsmith-0.2.1.tar.gz
Algorithm Hash digest
SHA256 dff59ebea096c0d97dbff30125b674989beb72d0f2395bef01cdbc6acff3080c
MD5 cb144ab1be6a39a1beb7025dc99a37d2
BLAKE2b-256 aeb6e9dd36335bbb21e33429877612bfec299876fdf9c4443bbfd26793911f3d

See more details on using hashes here.

File details

Details for the file toolsmith-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: toolsmith-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.2 Darwin/24.6.0

File hashes

Hashes for toolsmith-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 494eb86c2bfe481c09108a3bf320d489af8a95f1857e550eea7c518efe4b01c5
MD5 a9669a713d20b7e8a3faff5806c96735
BLAKE2b-256 9e29fcd7788217df99669f14fd757b09c65711c9b53693d228a1cde3509cbc91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page