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.

📂 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.2.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.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: telm-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 c86040f16b8846287549b1ed97ff7a7a688c6f9c3926889c4e49eac96d950d2b
MD5 771ada5f9296679c242e76619a7a6188
BLAKE2b-256 8f47cd7721b605900218a42f843b7381ff20b9b4d2afb122665216ac35275c9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: telm-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2aab83a0de53d9b043ba3c0b1a41394106bf39e8a4c1fc59004cadb3ff3a0623
MD5 b592db48610bbffdcc8907d3088206ec
BLAKE2b-256 47377dc5685d1bb44337f63b8d32455b590c63080f04f801f54552a480389ca6

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