Skip to main content

phago_embeddings/
lib.rs

1//! # Phago Embeddings
2//!
3//! Embedding backends for Phago semantic intelligence.
4//!
5//! This crate provides vector embeddings for semantic understanding:
6//! - Text → vector conversion
7//! - Similarity computation
8//! - Chunking and normalization
9//!
10//! ## Features
11//!
12//! - `local`: ONNX-based local embeddings (no API needed)
13//! - `api`: API-based embeddings (OpenAI, Voyage, etc.)
14//! - `full`: Both local and API support
15//!
16//! ## Usage
17//!
18//! ```rust,ignore
19//! use phago_embeddings::{Embedder, SimpleEmbedder};
20//!
21//! let embedder = SimpleEmbedder::new();
22//! let vector = embedder.embed("cell membrane transport");
23//! let similarity = embedder.cosine_similarity(&v1, &v2);
24//! ```
25
26mod embedder;
27mod simple;
28mod chunker;
29mod normalize;
30
31pub use embedder::{Embedder, EmbeddingError, EmbeddingResult};
32pub use simple::SimpleEmbedder;
33pub use chunker::{Chunker, ChunkConfig};
34pub use normalize::{
35    normalize_l2, normalize_l1, normalize_minmax, normalize_zscore,
36    cosine_similarity, euclidean_distance, dot_product,
37};
38
39#[cfg(feature = "local")]
40mod onnx;
41#[cfg(feature = "local")]
42pub use onnx::OnnxEmbedder;
43
44#[cfg(feature = "api")]
45mod api;
46#[cfg(feature = "api")]
47pub use api::{ApiEmbedder, ApiConfig};
48
49/// Prelude for convenient imports.
50pub mod prelude {
51    pub use crate::{Embedder, EmbeddingError, EmbeddingResult};
52    pub use crate::{SimpleEmbedder, Chunker, ChunkConfig};
53    pub use crate::{normalize_l2, cosine_similarity};
54
55    #[cfg(feature = "local")]
56    pub use crate::OnnxEmbedder;
57
58    #[cfg(feature = "api")]
59    pub use crate::{ApiEmbedder, ApiConfig};
60}