Skip to main content

sqlite_graphrag/extract/
embedding_backend.rs

1//! Embedding-based extraction backend (v1.0.75 — G21 legacy path)
2//!
3//! The legacy fastembed pipeline behind the `embedding-legacy` feature was
4//! REMOVED in v1.0.79 (originally scheduled for v1.1.0). This backend is a
5//! permanent stub kept only so `--extraction-backend embedding` keeps
6//! parsing and returns a clear migration error instead of an opaque one.
7
8use super::{BackendHealth, BackendKind, ExtractionBackend, ExtractionHints, ExtractionOutput};
9use crate::errors::AppError;
10use async_trait::async_trait;
11
12/// Embedding-based extraction backend (permanent stub since v1.0.79).
13pub struct EmbeddingBackend {
14    model_name: String,
15}
16
17impl EmbeddingBackend {
18    pub fn new() -> Self {
19        Self {
20            model_name: "multilingual-e5-small".to_string(),
21        }
22    }
23
24    pub fn with_model(model_name: impl Into<String>) -> Self {
25        Self {
26            model_name: model_name.into(),
27        }
28    }
29}
30
31impl Default for EmbeddingBackend {
32    fn default() -> Self {
33        Self::new()
34    }
35}
36
37#[async_trait]
38impl ExtractionBackend for EmbeddingBackend {
39    fn kind(&self) -> BackendKind {
40        BackendKind::Embedding
41    }
42
43    fn model_name(&self) -> String {
44        self.model_name.clone()
45    }
46
47    async fn extract(
48        &self,
49        _content: &str,
50        _hints: &ExtractionHints,
51    ) -> Result<ExtractionOutput, AppError> {
52        Err(AppError::Validation(format!(
53            "the legacy embedding extraction backend was removed in v1.0.79 \
54             (the CLI is LLM-only); use --extraction-backend llm instead. \
55             Model requested: {}",
56            self.model_name
57        )))
58    }
59
60    async fn health(&self) -> Result<BackendHealth, AppError> {
61        Ok(BackendHealth {
62            kind: self.kind(),
63            healthy: false,
64            model_name: self.model_name.clone(),
65            message: "legacy embedding backend removed in v1.0.79; use the llm backend".to_string(),
66        })
67    }
68}