sqlite_graphrag/extract/
embedding_backend.rs1use super::{BackendHealth, BackendKind, ExtractionBackend, ExtractionHints, ExtractionOutput};
9use crate::errors::AppError;
10use async_trait::async_trait;
11
12pub struct EmbeddingBackend {
14 model_name: String,
15}
16
17impl EmbeddingBackend {
18 pub fn new() -> Self {
20 Self {
21 model_name: crate::constants::SQLITE_GRAPHRAG_VERSION.to_string(),
22 }
23 }
24
25 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}