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.

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


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.0.tar.gz (5.0 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.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: toolsmith-0.2.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.9 Darwin/24.3.0

File hashes

Hashes for toolsmith-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e6ee656172ecdbd4b6c541db72574ee744a605cefae26fb817a9b49587fe9cb6
MD5 5154194b09fe861afcc55c6fa7e1087f
BLAKE2b-256 ce08942524dc10840eecb26cf5a76df019fa6744f5c624875219443a9ac454d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: toolsmith-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 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

Hashes for toolsmith-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01013578c695006c01c8f7cd9aef2ac631b6704fe3ea369eafa72c6139cfa63b
MD5 2fbae32d841d26416cd30229bcda728d
BLAKE2b-256 9dcaeba1904c1ab1d8984275a1af325f578c746f82584bd47ce1cf8198af403a

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