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 cacheimportance— heuristic importance scoring (no LLM)structured— JSON-LD / Microdata extraction from HTML (no LLM)provider— theLlmProvidertrait + 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
http(default) — enablesOpenAiCompatibleProvider, the reqwest-backed referenceLlmProvider.redis-cache(default) — enablesspam::RedisSpamCache, a Redis-backedspam::SpamCacheimplementation. Disable if you cache yourself or run without a cache.
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
LlmProviderwith an optional cache. - structured
- Schema.org JSON-LD extraction from HTML message bodies.
Structs§
- Open
AiCompatible Provider - Reference
LlmProviderbacked by an OpenAI-compatible HTTP endpoint.