airust
๐ง airust is a modular, trainable AI library in Rust.
It supports compile-time knowledge through JSON files and enables simple prediction engines for natural language inputs.
๐ Features
- ๐งฉ Modular architecture with the
TrainableAgenttrait - ๐ง Multiple built-in agents:
SimpleAgent(exact matching)FuzzyAgent(Levenshtein similarity)ContextAgent(considers conversation context)TfidfAgent(uses BM25 algorithm for better similarity matching)StructuredAgent(supports structured response formats)
- ๐พ Compile-time knowledge via
knowledge/train.json - โ๏ธ Weighted training data for more precise answers
- ๐ Extensible knowledge base at runtime
- ๐ Advanced text recognition with TF-IDF and BM25
- ๐ท๏ธ Support for structured responses (Text, Markdown, JSON)
- ๐ฆ Easy integration into other projects
- ๐ฅ๏ธ CLI test program included
๐ง Usage
In your project
[]
= { = "../airust" }
Example code
use SimpleAgent;
use TRAINING_DATA;
use TrainableAgent;
๐ Training Data
The file knowledge/train.json now also supports weights:
This file is automatically embedded in the binary at build time (build.rs takes care of this).
๐ฅ๏ธ CLI Usage
# Testing different agents
๐งช Testing the Extended Features
Context Agent Testing
# Start the interactive context test
The Context Agent stores previous questions and answers to deliver better results in connected conversations.
Dynamic Knowledge Base
# Test the dynamic knowledge database
With the dynamic knowledge base, you can at runtime:
- Add new training data
- Save and load the knowledge base
- Make changes to training data
Structured Responses
The StructuredAgent supports different response formats:
- Simple text
- Markdown formatted text
- JSON structured data
# Test structured responses
๐ Advanced Usage
BM25 Algorithm for Better Match Rates
The TfidfAgent uses the BM25 algorithm, an extension of the TF-IDF method, to better recognize semantic similarity between questions:
use TfidfAgent;
use TRAINING_DATA;
use TrainableAgent;
๐ License
MIT
Developed with โค๏ธ in Rust.
This crate is open for contributions and extensions.