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
//! Embedder trait — pluggable text-embedding backend.
//!
//! kglite supports semantic search via `text_score()` in Cypher
//! queries. To embed query strings at lookup time the graph holds
//! an optional embedder. This trait abstracts over the available
//! backends:
//!
//! - [`fastembed::FastEmbedAdapter`] (gated on the `fastembed`
//! Cargo feature) — Rust-native ONNX inference via
//! `fastembed-rs`.
//!
//! - `PyEmbedderAdapter` (in kglite-py) — wraps a user-provided
//! Python class. Used by the Python API path
//! (`g.set_embedder(my_python_obj)`). PyO3-only; not visible
//! here.
//!
//! Both implement [`Embedder`]; downstream consumers (the Cypher
//! engine's text-score rewrite, the `embed_texts` / `search_text`
//! pymethods) call through the trait without caring which backend
//! they got.
/// Pluggable text-embedding backend. Implementations must be
/// `Send + Sync` because the `KnowledgeGraph` is freely cloned
/// across threads (its `embedder` field is an `Arc<dyn Embedder>`).