Skip to main content

LlmBackendFactory

Trait LlmBackendFactory 

Source
pub trait LlmBackendFactory: Send + Sync {
    // Required methods
    fn build_extraction_backend(
        &self,
        config: &LlmExtractorConfig,
    ) -> Result<Box<dyn ExtractionBackend>, AppError>;
    fn build_embedder(
        &self,
        config: &LlmExtractorConfig,
    ) -> Result<Box<dyn Any + Send + Sync>, AppError>;
    fn kind(&self) -> LlmBackendKindFactory;
}
Expand description

Factory trait for LLM-based backends. Each implementation knows how to build the right CLI invocation (codex vs claude vs none) from the user-supplied LlmExtractorConfig.

The factory pattern exists so that:

  1. composite_backend.rs can dispatch to ANY backend via a boxed trait object without knowing the concrete type;
  2. --llm-backend=auto can probe PATH at runtime and pick the first available CLI;
  3. New backends (ollama, opencode, lm-studio) can be added in v1.0.83+ without changing the call sites that consume the factory.

Required Methods§

Source

fn build_extraction_backend( &self, config: &LlmExtractorConfig, ) -> Result<Box<dyn ExtractionBackend>, AppError>

Build an ExtractionBackend implementation ready to extract entities and relationships from a body.

Source

fn build_embedder( &self, config: &LlmExtractorConfig, ) -> Result<Box<dyn Any + Send + Sync>, AppError>

Build a query embedder (used by recall / hybrid-search).

Source

fn kind(&self) -> LlmBackendKindFactory

Short identifier for logging.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§