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:
agent_id (
str) – The agent learning this factfact (
str) – The factual statementdomain (
str) – Domain or category of knowledgeconfidence (
float) – Confidence in this fact (0.0 to 1.0)source (
Optional[str]) – Source of this informationrelated_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 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:
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 rulerule_name (
str) – Name of the rulerule_description (
str) – Description of what the rule doesconditions (
List[str]) – Conditions when the rule appliesactions (
List[str]) – Actions to take when conditions are metdomain (
str) – Domain of applicationconfidence (
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 fordomain (
str) – The domain to search inlimit (
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 forconcept (
str) – The concept to find relations forlimit (
int) – Maximum number of related concepts
- 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
- Parameters:
agent_id (
str) – The agent to check knowledge forstatement (
str) – The statement to validatethreshold (
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 knowledgeold_knowledge (
str) – The knowledge to updatenew_knowledge (
str) – The new knowledgereason (
str) – Reason for the update
- Return type:
bool- Returns:
True if update was successful