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 custom_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.1.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.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: telm-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 823728e3d96f85c3d1dfbfa0495e8ef43be579464f745c7e504e388812450e9a
MD5 3ec0b57c1a05950ef445cb8a178f662d
BLAKE2b-256 8b9dd34b36227ea60ad566e486eb6ba5a20fb42062c7d251b2ea0be9859d1da7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: telm-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c044957dbbcaacb55aae595a1fa5fe587ee1fdc969bb3e934df6eafcefdcd9c
MD5 45f8f4f6bdd5c936c14ec28be2263df9
BLAKE2b-256 f449fbf163cc2839d8e35e3da835b9b83d3a14bf21980403971eb36eee7b9f73

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