Skip to main content

LlmProvider

Trait LlmProvider 

Source
pub trait LlmProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn complete(&self, prompt: &str) -> Result<String>;
    fn analyze_for_capture(&self, content: &str) -> Result<CaptureAnalysis>;

    // Provided methods
    fn complete_with_system(&self, system: &str, user: &str) -> Result<String> { ... }
    fn analyze_for_capture_extended(
        &self,
        content: &str,
        existing_memories: Option<&str>,
    ) -> Result<ExtendedCaptureAnalysis> { ... }
    fn classify_search_intent(
        &self,
        prompt: &str,
    ) -> Result<ExtendedSearchIntent> { ... }
    fn analyze_for_consolidation(
        &self,
        memories: &str,
    ) -> Result<ConsolidationAnalysis> { ... }
}
Expand description

Trait for LLM providers.

Required Methods§

Source

fn name(&self) -> &'static str

The provider name.

Source

fn complete(&self, prompt: &str) -> Result<String>

Generates a completion for the given prompt.

§Errors

Returns an error if the completion fails.

Source

fn analyze_for_capture(&self, content: &str) -> Result<CaptureAnalysis>

Analyzes content for memory capture.

§Errors

Returns an error if analysis fails.

Provided Methods§

Source

fn complete_with_system(&self, system: &str, user: &str) -> Result<String>

Generates a completion with a system prompt.

§Errors

Returns an error if the completion fails.

Default implementation concatenates system and user prompts. Providers should override this to use native system prompt support.

Source

fn analyze_for_capture_extended( &self, content: &str, existing_memories: Option<&str>, ) -> Result<ExtendedCaptureAnalysis>

Analyzes content for memory capture with extended security analysis.

Uses the unified subcog system prompt for comprehensive analysis including adversarial detection and contradiction checking.

§Arguments
  • content - The content to analyze.
  • existing_memories - Optional context of existing memories for contradiction detection.
§Errors

Returns an error if analysis fails.

Source

fn classify_search_intent(&self, prompt: &str) -> Result<ExtendedSearchIntent>

Classifies search intent with namespace weights.

Uses the unified subcog system prompt for intent classification with enhanced topic extraction and namespace weighting.

§Errors

Returns an error if classification fails.

Source

fn analyze_for_consolidation( &self, memories: &str, ) -> Result<ConsolidationAnalysis>

Analyzes memories for consolidation.

Uses the unified subcog system prompt to identify merge candidates, archive candidates, and contradictions.

§Arguments
  • memories - JSON array of memories to analyze.
§Errors

Returns an error if analysis fails.

Implementors§