Skip to main content

Crate mailrs_intelligence

Crate mailrs_intelligence 

Source
Expand description

Email intelligence primitives — LLM-powered analysis with a pluggable provider.

mailrs-intelligence extracts the five analysis modules from the mailrs mail server:

  • analyze — full email analysis (category, summary, entities, intent)
  • spam — spam classification with an optional cache
  • importance — heuristic importance scoring (no LLM)
  • structured — JSON-LD / Microdata extraction from HTML (no LLM)
  • provider — the LlmProvider trait + an OpenAI-compatible reference impl

§Why a trait

Mail servers tend to mix cheap small-core inference (for hot paths like per-message classification) with occasional big-core calls (for rare, high-value structured extraction). Letting analysis functions take &dyn LlmProvider keeps that choice visible at the call site: every consumer can grep their own code for “which provider do I pass into analyze_email?” without diving into config.

§Quickstart

use mailrs_intelligence::{OpenAiCompatibleProvider, analyze::analyze_email};

let provider = OpenAiCompatibleProvider::new(
    "http://llm.example.com/complete".into(),
    Some("sk-…".into()),
    "qwen3.5-9b/v8".into(),
);

let analysis = analyze_email(
    &provider,
    "boss@example.com",
    "Q3 review",
    "Please send your Q3 self-review by Friday.",
)
.await?;

println!("category={} requires_action={}", analysis.category, analysis.requires_action);

§Feature flags

Disable both default features if you’re plugging in your own backends.

Re-exports§

pub use provider::LlmProvider;

Modules§

analyze
Full email analysis — category, summary, entities, intent, action deadline.
importance
Heuristic importance scoring (no LLM).
provider
Pluggable LLM provider trait (currently Claude / Ollama implementations).
spam
Spam classification via LlmProvider with an optional cache.
structured
Schema.org JSON-LD extraction from HTML message bodies.

Structs§

OpenAiCompatibleProvider
Reference LlmProvider backed by an OpenAI-compatible HTTP endpoint.