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:
composite_backend.rscan dispatch to ANY backend via a boxed trait object without knowing the concrete type;--llm-backend=autocan probe PATH at runtime and pick the first available CLI;- New backends (ollama, opencode, lm-studio) can be added in v1.0.83+ without changing the call sites that consume the factory.
Required Methods§
Sourcefn build_extraction_backend(
&self,
config: &LlmExtractorConfig,
) -> Result<Box<dyn ExtractionBackend>, AppError>
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.
Sourcefn build_embedder(
&self,
config: &LlmExtractorConfig,
) -> Result<Box<dyn Any + Send + Sync>, AppError>
fn build_embedder( &self, config: &LlmExtractorConfig, ) -> Result<Box<dyn Any + Send + Sync>, AppError>
Build a query embedder (used by recall / hybrid-search).
Sourcefn kind(&self) -> LlmBackendKindFactory
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".