pub struct CognitiveLlmService<J: LlmJudge> { /* private fields */ }Expand description
The unified LLM intelligence layer for memory operations.
Wraps any LlmJudge implementation and provides typed judgment methods
with specialized prompts for each cognitive task.
Implementations§
Source§impl<J: LlmJudge> CognitiveLlmService<J>
impl<J: LlmJudge> CognitiveLlmService<J>
Sourcepub async fn judge_invalidation(
&self,
old: &MemorySummary,
new: &MemorySummary,
) -> Result<InvalidationVerdict, LlmJudgeError>
pub async fn judge_invalidation( &self, old: &MemorySummary, new: &MemorySummary, ) -> Result<InvalidationVerdict, LlmJudgeError>
Determine whether a new memory invalidates an existing one.
This is the key method that replaces the cosine similarity heuristic for temporal invalidation. The LLM can understand that “Alice works at Acme” is invalidated by “Alice joined Google” even though the embeddings are quite different.
Sourcepub async fn detect_contradiction(
&self,
a: &MemorySummary,
b: &MemorySummary,
) -> Result<ContradictionVerdict, LlmJudgeError>
pub async fn detect_contradiction( &self, a: &MemorySummary, b: &MemorySummary, ) -> Result<ContradictionVerdict, LlmJudgeError>
Determine whether two memories contradict each other.
Sourcepub async fn resolve_entities(
&self,
candidates: &[EntityCandidate],
) -> Result<Vec<EntityMergeGroup>, LlmJudgeError>
pub async fn resolve_entities( &self, candidates: &[EntityCandidate], ) -> Result<Vec<EntityMergeGroup>, LlmJudgeError>
Resolve a batch of entity references into merge groups.
Sourcepub async fn consolidate(
&self,
cluster: &[ClusterMember],
) -> Result<ConsolidationDecision, LlmJudgeError>
pub async fn consolidate( &self, cluster: &[ClusterMember], ) -> Result<ConsolidationDecision, LlmJudgeError>
Decide how to consolidate a cluster of similar memories.
Sourcepub async fn canonicalize_topic(
&self,
message: &str,
existing_topics: &[String],
) -> Result<TopicLabel, LlmJudgeError>
pub async fn canonicalize_topic( &self, message: &str, existing_topics: &[String], ) -> Result<TopicLabel, LlmJudgeError>
Map a raw user message to a canonical topic label.
Sourcepub async fn generate_community_summary(
&self,
category: &str,
entities: &[(String, String)],
) -> Result<CommunitySummary, LlmJudgeError>
pub async fn generate_community_summary( &self, category: &str, entities: &[(String, String)], ) -> Result<CommunitySummary, LlmJudgeError>
Generate a summary for a community (cluster of related entities).
Sourcepub async fn generate_user_profile(
&self,
facts: &[String],
community_summaries: &[String],
) -> Result<UserProfile, LlmJudgeError>
pub async fn generate_user_profile( &self, facts: &[String], community_summaries: &[String], ) -> Result<UserProfile, LlmJudgeError>
Generate a user profile from accumulated knowledge.