airust
🧠 airust is a modular, trainable AI library written in Rust.
It supports compile-time knowledge through JSON files and allows for simple prediction engines for natural language input.
🚀 Features
-
🧩 Modular architecture with unified traits:
Agent– Base trait for all agentsTrainableAgent– For trainable agentsContextualAgent– For context-aware agents
-
🧠 Advanced agent implementations:
MatchAgent– Handles both exact and fuzzy matches (replacesSimpleAgentandFuzzyAgent)TfidfAgent– Uses the BM25 algorithm for improved similarity detectionContextAgent<A>– Generic wrapper for context-aware conversations
-
📝 Unified response format:
ResponseFormat– Supports responses in plain text, Markdown, and JSON
-
💾 Enhanced knowledge base:
- Compile-time knowledge via
knowledge/train.json - Runtime knowledge expansion supported
- Backward compatibility with older data formats
- Compile-time knowledge via
-
🛠️ Simplified CLI tool:
- Single CLI tool for all operations
- Interactive mode for testing and experimentation
- Knowledge base management capabilities
🔧 Usage
Integration in other projects
[]
= "0.1.4"
Sample Code (Updated)
use ;
📂 Training Data Format
The file format knowledge/train.json has been extended to support both the old and new format:
Legacy format is still supported for backward compatibility.
🖥️ CLI Usage
# Simple query
# Interactive mode
# Knowledge base management
📊 Advanced Usage – Context Agent
use ;
📃 License
MIT
Built with ❤️ in Rust.
Contributions and extensions are welcome!
🛠 Migration Guide for airust 0.1.4
This guide helps you migrate from airust 0.1.x to 0.1.4.
1. Trait and Type Changes
New Trait Hierarchy
New Response Format
let answer: ResponseFormat = agent.predict;
let answer_string: String = Stringfrom;
Updated TrainingExample Struct
2. Agent Replacements
SimpleAgent and FuzzyAgent → MatchAgent
let mut agent = new_exact;
let mut agent = new_fuzzy;
With options:
let mut agent = new;
ContextAgent is Now Generic
let mut base_agent = new;
base_agent.train;
let mut agent = new;
StructuredAgent Removed (use ResponseFormat)
3. Knowledge Base Changes
let kb = from_embedded;
let data = kb.get_examples;
let mut kb = new;
kb.add_example;
4. CLI Tool Migration
5. Recommendations
- Upgrade your dependencies
- Use new
lib.rsre-exports - Test thoroughly
- Explore new context formatting