Skip to main content

A lightweight tool normalization library for LLMs

Project description

🛠️ DynamicToolELM

A lightweight, flexible library to transform raw LLM text outputs into structured tool calls. Optimized for Small Language Models (SLM) and fine-tuned agents.

📋 Table of Contents

📂 Project Structure

|- telm.py              # Core logic & DynamicToolELM class
|- README.md            # Documentation
|- tools/               # Tool implementation modules
|   - __init__.py
|   - calculator.py
|   - datetime_utils.py
|   - weather.py
|   - websearch.py

🚀 Installation

pip install telm

💡 Concept

DynamicToolELM catches various LLM output formats and normalizes them into a clean, executable format: [action: argument]. It supports:

(action: value)

<action = value>

[action : value]

*action: value*

🛠️ Usage: LLM Integration (llama-cpp-python)

This example demonstrates how to use telm to intercept model responses and trigger specific functions.

from llama_cpp import Llama
from telm import DynamicToolELM

# Initialize LLM
llm = Llama(model_path="path/to/model.gguf", n_ctx=8192)


def send_picture(prompt):
    # logic to make an image
    return image_generated


# 1. Define Custom Tools
my_custom_tools = [
    {
        "name": "send_picture",
        "description": "Generate an image using Stable Diffusion",
        "parameters": {
            "type": "object",
            "properties": {"prompt": {"type": "string"}},
            "required": ["prompt"]
        }
    }
]

# 2. Initialize Managers
custom_tool_manager = DynamicToolELM(my_custom_tools)

# 3. Generate & Parse
response = llm.create_chat_completion(messages=messages, temperature=0.7)
raw_text = response["choices"][0]["message"]["content"].strip()

# Check for tool calls
custom_result = custom_manager.call_tool_elm(raw_text)

# 4. Handle Execution
if legacy_result["type"] in ["tool", "multi-tool"]:
    calls = result["results"] if result["type"] == "multi-tool" else [result]
    
    for call in calls:
        func_name = call.get("function")
        arg = call["args"].get("prompt_sup")

        if func_name == "send_picture":
            print(f"🎨 Generating image for: {arg}")
            send_picture(arg)

➕ How to add New Tools

Define it: Add a dictionary to your tools list describing the tool's name and purpose.

Execute it: Add a simple if func_name == "your_tool": check in your main loop to link the detection to your Python function.

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

telm-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

telm-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file telm-0.1.0.tar.gz.

File metadata

  • Download URL: telm-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for telm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60663ad248fc170c2ae6f8d94b7491a81bffe26e652d432723f1ad9e535ba8ed
MD5 65c1299f50d95981583e6b4d6a2214ef
BLAKE2b-256 293429341fb08bd4d4585915e77c039817c924fa01d476946d7b605e8fb93f70

See more details on using hashes here.

File details

Details for the file telm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: telm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for telm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 799b75136122699d9d01b9c806faffb0092a3a610f85edad747deadebc338e5f
MD5 2219c6666403e161d6e03a5749eb8938
BLAKE2b-256 84dd047b18ded705336ba086f1b10d588777893084c9b0178217aecbffa8c1ba

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