Skip to main content

Hot-Tool

PyPI version Python Version License

Build and package Python tools into standalone executables for LLM integration.

Features

  • Define Tools Simply - Inherit from HotTool class and implement required methods
  • LLM-Ready - Built-in support for function definitions compatible with OpenAI's function calling
  • Build Standalone Executables - Compile Python tools into single binary files using hot-tool build
  • Run Without Dependencies - Execute tools without Python installation or source code access

Installation

pip install hot-tool

Quick Start

Define Hot Tool

# get_my_ip.py
from typing import Optional

import requests

from hot_tool import FunctionDefinition, HotTool


class GetMyIpTool(HotTool):
    def function_definition(self) -> FunctionDefinition:
        return {
            "name": "get_my_ip",
            "description": "Get my IP address",
            "parameters": {},
        }

    def run(
        self, arguments: Optional[str] = None, context: Optional[str] = None
    ) -> str:
        response = requests.get("https://ifconfig.me")
        try:
            response.raise_for_status()
            return response.text.strip()
        except Exception as e:
            print(f"Error: {type(e).__name__}: {e}")
            return "Can not get my IP, please try again later."

Run Programmatically

# main.py
from get_my_ip import GetMyIpTool
from hot_tool.run import run_tool

print(run_tool(GetMyIpTool))
# 198.51.100.156

Build Standalone Executable and Run as Executable

hot-tool build get_my_ip.py -o get_my_ip
# Starting Nuitka compilation...
# ...
# Nuitka-Plugins:upx: Compressing 'get_my_ip'.
# Nuitka: Successfully created 'get_my_ip'.
# Compilation completed successfully.
# Standalone script saved to '/Users/me/path/to/get_my_ip'
./get_my_ip
# 198.51.100.156

Get Function Definition (for LLM Integration)

./get_my_ip function-definition
# {"name": "get_my_ip", "description": "Get my IP address", "parameters": {}}

This outputs the function definition in JSON format, compatible with OpenAI's function calling API. You can use this to dynamically register tools with LLMs.

You can also pass context to customize the function definition:

./get_my_ip function-definition --context "user prefers metric units"
# Function definition may be adjusted based on context

Required Methods

Every tool must implement two methods:

1. function_definition(context) → FunctionDefinition

Returns metadata about the tool for LLM integration. Can optionally accept context to customize the function definition dynamically.

  • context (Optional[str]): Additional context to customize the function definition

The FunctionDefinition TypedDict has the following structure:

{
    "name": str,              # Required: Tool name (e.g., "get_weather")
    "description": str,       # Optional: What the tool does
    "parameters": dict,       # Optional: Parameter descriptions
    "strict": bool,           # Optional: Strict mode for OpenAI
}

Example:

def function_definition(self, context: Optional[str] = None) -> FunctionDefinition:
    return {
        "name": "get_current_weather",
        "description": "Get the current weather of a city",
        "parameters": {
            "city_name": "The name of the city to get the current weather of",
        },
    }

2. run(arguments, context) → str

Executes the tool logic and returns a string result.

  • arguments (Optional[str]): JSON string containing input parameters
  • context (Optional[str]): Additional context information
  • Returns: String output for the LLM

Example:

def run(
    self, arguments: Optional[str] = None, context: Optional[str] = None
) -> str:
    import json
    args = json.loads(arguments or "{}")
    city_name = args.get("city_name", "New York")
    # ... your logic here ...
    return "Current weather: Sunny, 72°F"

Advanced Usage

Tool Inheritance for Reusability

You can create reusable base tool classes and import them into your scripts:

# base_tool.py
from hot_tool import HotTool

class BaseAPITool(HotTool):
    def run(self, arguments=None, context=None):
        # Shared logic here
        return self.call_api()
# my_tool.py - Your main script
from base_tool import BaseAPITool

class MyCustomTool(BaseAPITool):  # Inherit from your base class
    def run(self, arguments=None, context=None):
        # Custom implementation
        return "Custom result"

Important: Each script can only define one concrete tool class that implements both run() and function_definition(). Imported base classes don't count toward this limit.

License

MIT License

Metadata

Release files for hot-tool 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hot-tool 0.0.5
File Size Uploaded
hot_tool-0.0.5.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hot-tool 0.0.5
File Interpreter ABI Platform
hot_tool-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 15.8 kB

Release files / hot_tool-0.0.5.tar.gz

Download URL hot_tool-0.0.5.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0d0e5971618a8bd2fc6be804c271256b8a13de6eb96d5bbf9dbb4bf36ec604df
BLAKE2b-256 checksum
How to use checksums
af2324129b0207797b87c8eae985c46b2744ccf41c31007661ab952410723dad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.14 Darwin/25.1.0

Release files / hot_tool-0.0.5-py3-none-any.whl

Download URL hot_tool-0.0.5-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03f40f8887cbc025a7eaef8fd3596758f82dc85b391d7563301e1085f27f19ac
BLAKE2b-256 checksum
How to use checksums
5874715b0910a0c7f7825f8b547ea7d000bfbdbbab25d858c249f99ab48d8be5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.14 Darwin/25.1.0

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page