pub async fn embed_prepass<F>(
messages: &[Message],
embed: &F,
config: &FidelityConfig,
inserted_count: usize,
) -> HashMap<usize, Vec<f32>>Expand description
Run embed calls for messages concurrently, returning per-index embedding vectors.
Indexes not included in the result either had no content, already had an embedding
cached in msg.metadata.embedding, or produced an error (errors are logged at warn
level and silently skipped — scoring falls back to keyword overlap for those messages).
Each embed call is bounded by FidelityConfig::embed_timeout_secs; timed-out messages
are skipped with a warn-level log.
Only exempt messages (focus-pinned, inserted memory, system) are skipped; for non-exempt messages the content
is optionally truncated to config.max_embed_input_tokens * 4 bytes (at a char boundary)
before the call.
Concurrency is bounded by FidelityConfig::embed_concurrency (default 32), which
maps to the buffer_unordered(N) parameter. A zero value is clamped to 1 with a warning.
§Examples
use zeph_context::fidelity::{embed_prepass, FidelityConfig};
async fn example() {
let messages = vec![];
let cfg = FidelityConfig::default();
let embed = |_text: &str| -> zeph_llm::provider::EmbedFuture {
Box::pin(async { Ok(vec![0.0f32; 384]) })
};
let _embeddings = embed_prepass(&messages, &embed, &cfg, 0).await;
}