🌓
tiny_fnc_engine Documentation
Welcome to the tiny_fnc_engine documentation. Use the sidebar to navigate through different sections of the documentation.
Introduction
tiny_fnc_engine is a minimal Python library that provides a flexible engine for calling functions extracted from Large Language Model (LLM) outputs in JSON format. The engine stores functions and their outputs in memory, allowing for chained function calls and parameter referencing.
Features
- Add and call functions dynamically
- Parse function calls from JSON or string format
- Chain multiple function calls
- Store and reference function outputs
- Support for Pydantic models as function parameters and return values
- Reset session to clear stored outputs
- Minimal codebase (one file, 211 lines of code)
- Parse & call functions from OpenAI compatible "tool_calls" format
Quickstart
from tiny_fnc_engine import FunctionCallingEngine
# Initialize the engine
engine = FunctionCallingEngine()
# Add functions to the engine
def greet(name):
return f"Hello, {name}!"
engine.add_functions([greet])
# Call a function using JSON format
result = engine.parse_and_call_functions({
"name": "greet",
"parameters": {"name": "Alice"},
"returns": [{"name": "greeting", "type": "str"}]
})
print(result[0]) # Output: Hello, Alice!