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    /// Create a new instance.
19    pub fn new() -> Self {
20        Self {
21            model_name: crate::constants::SQLITE_GRAPHRAG_VERSION.to_string(),
22        }
23    }
24
25    /// With model.
26    pub fn with_model(model_name: impl Into<String>) -> Self {
27        Self {
28            model_name: model_name.into(),
29        }
30    }
31}
32
33impl Default for EmbeddingBackend {
34    fn default() -> Self {
35        Self::new()
36    }
37}
38
39#[async_trait]
40impl ExtractionBackend for EmbeddingBackend {
41    fn kind(&self) -> BackendKind {
42        BackendKind::Embedding
43    }
44
45    fn model_name(&self) -> String {
46        self.model_name.clone()
47    }
48
49    async fn extract(
50        &self,
51        _content: &str,
52        _hints: &ExtractionHints,
53    ) -> Result<ExtractionOutput, AppError> {
54        Err(AppError::Validation(crate::i18n::validation::legacy_embedding_backend_removed(&self.model_name)))
55    }
56
57    async fn health(&self) -> Result<BackendHealth, AppError> {
58        Ok(BackendHealth {
59            kind: self.kind(),
60            healthy: false,
61            model_name: self.model_name.clone(),
62            message: "legacy embedding backend removed in v1.0.79; use the llm backend".to_string(),
63        })
64    }
65}