airust
๐ง airust is a modular, trainable AI library written in Rust.
It supports compile-time knowledge through JSON files and provides sophisticated prediction engines for natural language input.
๐ AiRust Capabilities
โ What You Can Concretely Do:
๐ง 1. Build Your Own AI Agents
- Train agents with examples (Question โ Answer)
- Supported Agent Types:
- Exact Match โ precise matching
- Fuzzy Match โ tolerant to typos (Levenshtein)
- TF-IDF/BM25 โ semantic similarity
- ContextAgent โ remembers previous dialogues
๐ฌ 2. Manage Your Own Knowledge Database
- Save/load training data (
train.json) - Weighting and metadata per entry
- Import legacy data possible
๐งช 3. Text Analysis
- Tokenization, stop words, N-grams
- Similarity measures: Levenshtein, Jaccard
- Text normalization
๐งฐ 4. Custom CLI Tools
- Launch
airustCLI for:- Interactive sessions with an agent
- Knowledge base management
- Quick data testing
๐ 5. Integration into Other Projects
- Use
airustas a Rust library in your own applications (Web, CLI, Desktop, IoT)
๐ง Example Application Ideas:
- ๐ค FAQ Bot for your website
- ๐ Intelligent document search
- ๐งพ Customer support via terminal
- ๐ฃ๏ธ Voice assistant with context understanding
- ๐ Similarity search for text databases
- ๐ Local assistance tool for developer documentation
๐ Advanced Features
-
๐งฉ Modular Architecture with Unified Traits:
Agentโ Base trait for all agents with enhanced prediction capabilitiesTrainableAgentโ For agents that can be trained with examplesContextualAgentโ For context-aware conversational agentsConfidenceAgentโ New trait for agents that can provide prediction confidence
-
๐ง Intelligent Agent Implementations:
MatchAgentโ Advanced matching with configurable strategies- Exact matching
- Fuzzy matching with dynamic thresholds
- Configurable Levenshtein distance options
TfidfAgentโ Sophisticated similarity detection using BM25 algorithm- Customizable term frequency scaling
- Document length normalization
ContextAgent<A>โ Flexible context-aware wrapper- Multiple context formatting strategies
- Configurable context history size
-
๐ Enhanced Response Handling:
ResponseFormatwith support for:- Plain text
- Markdown
- JSON
- Metadata and confidence tracking
- Seamless type conversions
-
๐พ Intelligent Knowledge Base:
- Compile-time knowledge via
train.json - Runtime knowledge expansion
- Backward compatibility with legacy formats
- Weighted training examples
- Optional metadata support
- Compile-time knowledge via
-
๐ Advanced Text Processing:
- Tokenization with Unicode support
- Stopword removal
- Text normalization
- N-gram generation
- Advanced string similarity metrics
- Levenshtein distance
- Jaccard similarity
-
๐ ๏ธ Unified CLI Tool:
- Interactive mode
- Multiple agent type selection
- Knowledge base management
- Flexible querying
๐ง 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 ;
๐ New in Version 0.1.4
Matching Strategies
// Configurable fuzzy matching
let agent = new;
Context Formatting
// Multiple context representation strategies
let context_agent = new
.with_context_format;
// Other formats: QAPairs, Sentence, Custom
Advanced Text Utilities
// Text processing capabilities
let tokens = tokenize;
let unique_terms = unique_terms;
let ngrams = create_ngrams;
๐ 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