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
|
Manages semantic memories - facts, concepts, and knowledge |
- class praval.memory.semantic_memory.SemanticMemory(long_term_memory)[source]๏
Bases:
objectManages 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:
- Return type:
- 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 conceptconcept (
str) โ The concept namedefinition (
str) โ Definition of the conceptdomain (
str) โ Domain or field of the conceptproperties (
Optional[Dict[str,Any]]) โ Properties or attributes of the conceptrelationships (
Optional[Dict[str,List[str]]]) โ Relationships to other concepts (e.g., {โis_aโ: [โcategoryโ], โrelates_toโ: [โother_conceptsโ]})
- Return type:
- 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:
- Return type:
- Returns:
The memory ID
- get_knowledge_in_domain(agent_id, domain, limit=50)[source]๏
Get all knowledge in a specific domain
- Parameters:
- Return type:
- Returns:
List of semantic memories in the domain
Find concepts related to a given concept
- Parameters:
- Return type:
- Returns:
Search results with related concepts
- validate_knowledge(agent_id, statement, threshold=0.8)[source]๏
Check if a statement is consistent with stored knowledge
- update_knowledge(agent_id, old_knowledge, new_knowledge, reason='Updated information')[source]๏
Update existing knowledge with new information