praval.memory.semantic_memory๏ƒ

Semantic memory for Praval agents - knowledge, facts, and concepts

This manages: - Factual knowledge storage - Concept relationships - Domain expertise - Learned information persistence

Classes

SemanticMemory(long_term_memory)

Manages semantic memories - facts, concepts, and knowledge

class praval.memory.semantic_memory.SemanticMemory(long_term_memory)[source]๏ƒ

Bases: object

Manages semantic memories - facts, concepts, and knowledge

Features: - Factual knowledge storage - Concept relationship tracking - Knowledge validation and updating - Domain expertise building

Parameters:

long_term_memory (LongTermMemory)

__init__(long_term_memory)[source]๏ƒ

Initialize semantic memory

Parameters:

long_term_memory (LongTermMemory) โ€“ Long-term memory backend for persistence

store_fact(agent_id, fact, domain, confidence=1.0, source=None, related_concepts=None)[source]๏ƒ

Store a factual piece of knowledge

Parameters:
  • agent_id (str) โ€“ The agent learning this fact

  • fact (str) โ€“ The factual statement

  • domain (str) โ€“ Domain or category of knowledge

  • confidence (float) โ€“ Confidence in this fact (0.0 to 1.0)

  • source (Optional[str]) โ€“ Source of this information

  • related_concepts (Optional[List[str]]) โ€“ Related concepts or topics

Return type:

str

Returns:

The memory ID

store_concept(agent_id, concept, definition, domain, properties=None, relationships=None)[source]๏ƒ

Store a concept with its definition and relationships

Parameters:
  • agent_id (str) โ€“ The agent learning this concept

  • concept (str) โ€“ The concept name

  • definition (str) โ€“ Definition of the concept

  • domain (str) โ€“ Domain or field of the concept

  • properties (Optional[Dict[str, Any]]) โ€“ Properties or attributes of the concept

  • relationships (Optional[Dict[str, List[str]]]) โ€“ Relationships to other concepts (e.g., {โ€œis_aโ€: [โ€œcategoryโ€], โ€œrelates_toโ€: [โ€œother_conceptsโ€]})

Return type:

str

Returns:

The memory ID

store_rule(agent_id, rule_name, rule_description, conditions, actions, domain, confidence=1.0)[source]๏ƒ

Store a procedural rule or pattern

Parameters:
  • agent_id (str) โ€“ The agent learning this rule

  • rule_name (str) โ€“ Name of the rule

  • rule_description (str) โ€“ Description of what the rule does

  • conditions (List[str]) โ€“ Conditions when the rule applies

  • actions (List[str]) โ€“ Actions to take when conditions are met

  • domain (str) โ€“ Domain of application

  • confidence (float) โ€“ Confidence in this rule

Return type:

str

Returns:

The memory ID

get_knowledge_in_domain(agent_id, domain, limit=50)[source]๏ƒ

Get all knowledge in a specific domain

Parameters:
  • agent_id (str) โ€“ The agent to get knowledge for

  • domain (str) โ€“ The domain to search in

  • limit (int) โ€“ Maximum number of entries to return

Return type:

List[MemoryEntry]

Returns:

List of semantic memories in the domain

Find concepts related to a given concept

Parameters:
  • agent_id (str) โ€“ The agent to search for

  • concept (str) โ€“ The concept to find relations for

  • limit (int) โ€“ Maximum number of related concepts

Return type:

MemorySearchResult

Returns:

Search results with related concepts

validate_knowledge(agent_id, statement, threshold=0.8)[source]๏ƒ

Check if a statement is consistent with stored knowledge

Parameters:
  • agent_id (str) โ€“ The agent to check knowledge for

  • statement (str) โ€“ The statement to validate

  • threshold (float) โ€“ Similarity threshold for matching

Return type:

Dict[str, Any]

Returns:

Validation result with confidence and supporting evidence

update_knowledge(agent_id, old_knowledge, new_knowledge, reason='Updated information')[source]๏ƒ

Update existing knowledge with new information

Parameters:
  • agent_id (str) โ€“ The agent updating knowledge

  • old_knowledge (str) โ€“ The knowledge to update

  • new_knowledge (str) โ€“ The new knowledge

  • reason (str) โ€“ Reason for the update

Return type:

bool

Returns:

True if update was successful

get_domain_expertise_level(agent_id, domain)[source]๏ƒ

Assess the agentโ€™s expertise level in a domain

Parameters:
  • agent_id (str) โ€“ The agent to assess

  • domain (str) โ€“ The domain to assess expertise in

Return type:

Dict[str, Any]

Returns:

Expertise assessment with metrics

get_stats()[source]๏ƒ

Get semantic memory statistics

Return type:

Dict[str, Any]