Skip to main content

Crate airust

Crate airust 

Source
Expand description

§AIRust 0.1.9

A Modular Knowledge Intelligence Engine

AIRust is a Rust library for finding information, comparing text, and suggesting possible connections. Give it entries with IDs, text, and optional metadata. Your application decides how to display and store the results.

Version 0.1.9 adds English documentation and interfaces, safer persistence and process controls, and hardened optional web tools. See the release notes and crates.io package.

§What it does

OperationResultUseful for
search()Relevant entries ranked with BM25. TF-IDF is also available.Finding notes and document passages.
find_matches()Exact matches, spelling similarity, or shared words. Rust also accepts r#match().Reviewing duplicates and similar content.
relate()Suggested connections with the shared terms that explain them.Helping users review possible links.

These methods compare words and characters. They do not automatically recognize synonyms or infer meaning. A calling application can add a language model or semantic embeddings when it needs those capabilities. AIRust has no required LLM dependency.

A relationship suggestion is evidence of shared words. The application must decide whether that evidence supports a useful connection, hierarchy, prerequisite, or contradiction.

§Try the source checkout

Use Rust 1.89 or newer. From the project directory:

cargo run --locked --example core

The example demonstrates search, text comparison, duplicates, relation suggestions, filters, and JSON round trips.

§Add AIRust to an application

Add AIRust to your Cargo.toml:

[dependencies]
airust = "0.1.9"

For local source development, use the checkout path instead:

[dependencies]
airust = { path = "../airust-master" }

A complete example:

use airust::{Engine, KnowledgeEntry};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut knowledge = Engine::new();
    knowledge.upsert(KnowledgeEntry::new(
        "note-1",
        "Rust provides memory safety without a garbage collector.",
    ))?;
    knowledge.upsert(KnowledgeEntry::new(
        "note-2",
        "Python is useful for scripting.",
    ))?;

    let results = knowledge.search("Rust memory", 5);
    assert_eq!(results[0].entry.id, "note-1");
    println!("{}", results[0].entry.text);

    let matches = knowledge.find_matches(
        "Rust provides memory safety without a garbage collector.",
        5,
    );
    assert_eq!(matches[0].score, 1.0);

    knowledge.upsert(KnowledgeEntry::new("note-2", "Python helps with automation."))?;
    knowledge.remove("note-2");

    let restored = Engine::from_json(&knowledge.to_json()?)?;
    assert_eq!(restored.len(), 1);
    Ok(())
}

Your application owns the IDs, storage model, and presentation. AIRust accepts the same entry format from document tools, graph applications, and agent services.

Search results contain the original entry, a relevance score, and matching terms. A query without a match returns an empty list. BM25 scores are relevance values, not probabilities. Equal scores use ascending entry IDs for a stable order.

§Optional integrations

The default build is the library. PDF processing, HTTP, SQLite, bots, command-line programs, and embedded sample knowledge are enabled explicitly.

Cargo featureEnables
NoneKnowledge index, BM25, TF-IDF, matching, duplicates, filters, and relation suggestions.
cliThe existing command-line programs and embedded sample knowledge.
pdfPDF text extraction and chunking.
webThe existing dashboard, HTTP, SQLite, bots, PDF, and CLI.
botsA compatibility name for the existing web and bot integration.
embedded-knowledgeSample data from knowledge/train.json at build time.

The existing MatchAgent, TfidfAgent, ContextAgent, and KnowledgeBase adapters remain available. The historical TfidfAgent name uses the shared BM25 index. The actual TF-IDF search mode is SearchAlgorithm::Tfidf.

§Run the tools

Run a stored-answer query:

cargo run --locked --features cli --bin airust -- cli query tfidf "What is AIRust?"

Convert a sample PDF into training data:

cargo run --locked --features cli,pdf --bin pdf2kb -- data/pdf/sample.pdf /tmp/airust-sample.json

Start the optional dashboard:

cargo run --locked --features web --bin airust

The default dashboard address is http://127.0.0.1:7070. The console uses port 7071. Administration is disabled by default; network-facing operation requires a configured API token. Follow STARTUP.md and the security guide for configuration.

§Project layout

LocationPurpose
src/text.rsShared tokenization and Unicode normalization.
src/matching.rsCharacter and token comparisons.
src/search.rsSearch modes, BM25 settings, and result types.
src/context.rsSearch filters for IDs and metadata.
src/knowledge.rsGeneric knowledge entries and the existing training collection.
src/index.rsShared storage and retrieval operations.
src/agent.rs, src/*_agent.rsCompatibility with the existing agent API.
src/pdf_loader.rs, src/bin/, src/web/Import and user-interface integrations.
examples/Runnable examples, a small runtime comparison, and a scalable index benchmark.
tests/Cross-module tests and regression cases.
docs/API contracts, architecture, migration, and change reports.
knowledge/, data/pdf/Sample knowledge and a PDF fixture.
airust.dbExisting local dashboard database, excluded from the crate package.
backups/The preserved original archive, excluded from the crate package.
build.rsCopies optional sample knowledge into the build directory.
Dockerfile, .dockerignoreContainer configuration for the dashboard.
test.sh, .github/workflows/ci.ymlRepeatable validation.

The API guide describes the public contracts. The architecture guide explains how the modules work together. Source code is kept free of comments; explanations live in these documents and executable examples.

§Changes and compatibility

See the 0.1.9 change report and 0.1.9 migration guide for the English-language and hardening work.

The roadmap describes optional semantic providers, evidence-based relations, persistence, and generic structural context as future work. External application integration follows a tested engine release.

The published 0.1.8 baseline is described in the 0.1.8 change report. The original analysis records what existed in 0.1.7. CHANGELOG.md lists the versions.

§Validate a change

./test.sh
cargo doc --locked --no-deps --open

The script checks formatting, the default library, optional integrations, documentation examples, and Clippy. Validation results for a particular version belong in its change report.

§License

MIT. See LICENSE.

Re-exports§

pub use agent::ConfidenceAgent;
pub use agent::Agent;
pub use agent::AgentError;
pub use agent::ContextualAgent;
pub use agent::ResponseFormat;
pub use agent::TrainableAgent;
pub use agent::TrainingExample;
pub use context::Context;
pub use index::IndexError;
pub use index::IndexStats;
pub use index::KnowledgeIndex;
pub use knowledge::KnowledgeEntry;
pub use knowledge::RelationKind;
pub use knowledge::RelationSuggestion;
pub use matching::compare;
pub use matching::MatchError;
pub use matching::MatchOptions;
pub use matching::MatchResult;
pub use matching::MatchStrategy;
pub use matching::Similarity;
pub use search::Bm25Config;
pub use search::SearchAlgorithm;
pub use search::SearchError;
pub use search::SearchOptions;
pub use search::SearchResult;
pub use context_agent::ContextAgent;
pub use knowledge::KnowledgeBase;
pub use match_agent::MatchAgent;
pub use pdf_loader::pdf_to_knowledge_base;
pub use pdf_loader::pdf_to_training_examples;
pub use pdf_loader::PageContent;
pub use pdf_loader::PdfLoader;
pub use pdf_loader::PdfLoaderConfig;
pub use tfidf_agent::TfidfAgent;

Modules§

agent
context
context_agent
index
knowledge
match_agent
matching
pdf_loader
search
text
tfidf_agent
web

Constants§

NAME
VERSION

Functions§

library_description
version_info

Type Aliases§

Engine