Skip to main content

mnem_llm_providers/
lib.rs

1// OpenAI, Ollama, Anthropic proper-noun identifiers appear throughout
2// the provider docs; backticking them adds no signal.
3#![allow(clippy::doc_markdown)]
4
5//! # mnem-llm-providers
6//!
7//! Text-generation adapters for mnem. Ships OpenAI chat completions
8//! and Ollama chat out of the box; both behind opt-in (on-by-default)
9//! cargo features.
10//!
11//! ## Scope
12//!
13//! Per [`mnem_core::llm`], `mnem-core` defines a
14//! [`TextGenerator`][mnem_core::llm::TextGenerator]
15//! trait. This crate provides the production adapters. Used today by
16//! `mnem retrieve --hyde`. The multi-query / RAG-Fusion variant is
17//! planned and will share the same trait. Future LLM-in-the-loop
18//! features (query rewriting, answer synthesis, retrieval grading)
19//! will build on this surface too.
20//!
21//! ## Invariants
22//!
23//! - **No tokio / no async.** All adapters are sync, built on top of
24//!   [`ureq`] (rustls-backed). Matches `mnem-embed-providers` and
25//!   `mnem-rerank-providers`.
26//! - **No API keys in config / on disk.** The config stores the *name*
27//!   of the env var holding the key (`api_key_env`). The key itself is
28//!   read from the environment at adapter-construction time.
29//! - **`mnem-core` stays on no HTTP client.** `mnem-core` still has
30//!   zero network / HTTP / tokio in its dep tree, preserving the
31//!   WASM-embeddability promises.
32
33#![forbid(unsafe_code)]
34#![deny(missing_docs)]
35
36pub mod config;
37pub(crate) mod http;
38
39#[cfg(feature = "ollama")]
40pub mod ollama;
41#[cfg(feature = "openai")]
42pub mod openai;
43
44pub use config::{OllamaLlmConfig, OpenAiLlmConfig, ProviderConfig, open};