1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Provider-agnostic embedding trait for polychrome.
//!
//! This crate defines the [`EmbeddingProvider`] trait that every concrete
//! embedding backend implements. It is the embedding-side analogue of
//! `polyc-llm`'s [`LlmProvider`](https://docs.rs/polyc-llm): a thin
//! seam so the tool-search layer can swap backends — pure-Rust static
//! embeddings (`model2vec-rs`) by default, a heavier transformer
//! (candle + `EmbeddingGemma`) when shallow matching isn't enough — without
//! touching its own code.
//!
//! Tool retrieval is a shallow-semantic task over short strings (a query vs.
//! tool name+description), so the default backend is intentionally tiny and
//! fully deterministic: a fixed lookup table + mean pooling embeds bit-for-bit
//! identically for a pinned model across hardware, which lines up with the
//! reproducible prompt-hash discipline elsewhere in the system.
//!
//! # Modules
//!
//! - [`error`] — the [`EmbeddingError`] bound that [`EmbeddingProvider::Error`]
//! must satisfy.
//! - [`erased`] — type erasure to a single [`DynEmbeddingProvider`] trait
//! object, mirroring `polyc-llm`'s `erased` module.
use async_trait;
pub use ;
pub use EmbeddingError;
/// The seam between the tool-search engine and any concrete embedding backend.
///
/// One implementation per backend, dispatched behind a trait object so the
/// retrieval layer swaps backends without recompiling. The `'static` bound and
/// [`Send`] + [`Sync`] make providers storable in the control plane and
/// shareable across tasks. [`Self::Error`] is bounded by [`EmbeddingError`] so
/// failures are uniform across backends while each keeps its own concrete error.
///
/// `model_id` and `dimensions` are pinned, cheap getters: the `model_id` is
/// recorded in the event log alongside a retrieval set so a result is
/// reproducible, and `dimensions` lets callers size an index without a probe
/// embed.