OlympiaAI/raix
Ruby AI eXtensions
What it solves
Raix is a Ruby library designed to integrate discrete AI components into existing Ruby applications. It simplifies the process of adding LLM capabilities—such as chat completions, tool use, and prompt chaining—without requiring the developer to manually manage complex API interactions or conversation transcripts.
How it works
Raix provides three mix-in modules that can be added to any Ruby class to grant it AI capabilities:
- ChatCompletion: The core module that manages conversation transcripts and provides methods to interact with LLMs via RubyLLM (supporting OpenAI, Anthropic, Google Gemini, and OpenRouter).
- FunctionDispatch: A declarative DSL for defining tool functions that the AI can call. It automatically handles the execution of these functions, adds the results back to the transcript, and continues the conversation loop until a final text response is generated.
- PromptDeclarations: A DSL for creating "prompt chains," allowing developers to define a sequence of prompts or callable prompt objects that are executed in order.
Who it’s for
Ruby developers who want to add LLM-powered features to their applications (including non-Rails apps) using a structured, modular approach based on proven patterns from the Olympia AI platform.
Highlights
- Unified Provider Access: Supports multiple LLM providers through RubyLLM and OpenRouter.
- Automatic Tool Loop: Seamlessly executes function calls and feeds results back to the AI without manual intervention.
- Flexible Hooks: Includes a
before_completionhook system (global, class, and instance levels) for dynamic parameter resolution, PII redaction, and logging. - JSON Mode: Built-in support for structured JSON responses, including fallback mechanisms for models that don't natively support a JSON response format.
- Prompt Caching: Support for Anthropic-style prompt caching to reduce latency and cost for large text bodies.
- Customizable Dispatch: Allows overriding function dispatch logic for adding caching (via ActiveSupport) or custom error handling.
Related
- Dispatch
- Project
- Project
- Project
- Project