openfunctions-rs 0.1.0

A universal framework for creating and managing LLM tools and agents
Documentation

OpenFunctions

Crates.io Documentation CI License

A universal framework for creating and managing LLM tools and agents.

OpenFunctions is a Rust-powered framework that enables you to build and deploy powerful tools and agents for Large Language Models. Write your functions in Bash, JavaScript, or Python, and let OpenFunctions handle the parsing, execution, and integration, so you can focus on building great AI-powered applications.

Features

  • Multi-Language Support: Write tools in Bash, JavaScript, or Python.
  • Agent Framework: Build complex AI agents with multiple tools and custom instructions.
  • Automatic Parsing: Tool definitions are automatically parsed from comments in your code.
  • High-Performance Runtime: Built with Rust and Tokio for fast and efficient execution.
  • Extensible: Designed to be modular and easy to extend with new languages and features.
  • Professional Tooling: Comes with a built-in test runner, dependency checker, and build system.

Quick Start

Installation

Add this to your Cargo.toml:

[dependencies]
openfunctions-rs = "0.1"

Or install the CLI tool:

cargo install openfunctions-rs

1. Create a Tool

Create a tool file, for example, tools/greet.sh:

#!/usr/bin/env bash
# @describe A simple tool to greet someone
# @option --name! The name to greet

echo "Hello, $argc_name!"

2. Run the Tool

# Build and test your tools
openfunctions build
openfunctions test

# Check your environment
openfunctions check

Documentation

Defining Tools

Tool definitions are extracted from specially formatted comments in your code.

Bash (.sh)

# @describe A description of the tool.
# @option --param! A required parameter.
# @flag --verbose A boolean flag.
# @env API_KEY! A required environment variable.

JavaScript (.js)

/**
 * A description of the tool.
 * @property {string} param - A required parameter.
 * @property {boolean} [verbose] - An optional parameter.
 */

Python (.py)

def run(param: str, verbose: bool = False):
    """
    A description of the tool.

    Args:
        param: The description for this parameter.
        verbose: The description for this flag.
    """
    pass

Project Configuration

Create an openfunctions.toml file in your project root to configure settings:

[project]
name = "my-openfunctions-project"
version = "0.1.0"

[runtime]
execution_timeout = 60 # in seconds

# Directories where your tools and agents are stored
tool_dirs = ["tools"]
agent_dirs = ["agents"]

Architecture

OpenFunctions is built with a modular architecture:

  • Core: Contains the central structs and logic for Tool, Agent, Registry, Builder, Checker, and TestRunner.
  • Models: Defines the data structures used throughout the framework, like ToolDefinition and AgentDefinition.
  • Parser: Responsible for parsing tool definitions from source code for different languages.
  • Runtime: The execution engine for running tools in a controlled environment.
  • CLI: A command-line interface for interacting with the framework.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.