class Memory: def __init__(self, memory_id, content, timestamp, importance, relevance, associated_tags): self.memory_id = memory_id self.content = content self.timestamp = timestamp self.importance = importance self.relevance = relevance self.associated_tags = associated_tags class Tag: def __init__(self, tag_id, tag_name): self.tag_id = tag_id self.tag_name = tag_name # // # class Category: def __init__(self, category_id, name, details): self.category_id = category_id self.name = name self.details = details self.embedding_ollama = embedding_ollama class Skill: # or "hat". used to help with the context. more specific than category def __init__(self, category_id, name): self.category_id = category_id self.name = name class Fact: def __init__(self, category_id, certainty, embedding_ollama): self.category_id = category_id self.certainty = certainty self.embedding_ollama = embedding_ollama class Context: def __init__(self): self.memories = [] self.facts = [] self.skills = [] self.tags = [] self.categories = [] def add_memory(self, memory): self.memories.append(memory) def add_fact(self, fact): self.facts.append(fact) def add_skill(self, skill): self.skills.append(skill) def add_tag(self, tag): self.tags.append(tag) def add_category(self, category): self.categories.append(category) def retrieve_memories(self, filter_tags=None): if filter_tags: return [memory for memory in self.memories if any(tag in memory.associated_tags for tag in filter_tags)] return self.memories def retrieve_facts(self, certainty_threshold): return [fact for fact in self.facts if fact.certainty >= certainty_threshold] def update_memory_relevance(self, memory_id, new_relevance): for memory in self.memories: if memory.memory_id == memory_id: memory.relevance = new_relevance break def summarize_context(self): # This method could be designed to summarize the current state of the context # For simplicity, it just prints out the counts of different entities print(f"Memories: {len(self.memories)}") print(f"Facts: {len(self.facts)}") print(f"Skills: {len(self.skills)}") print(f"Tags: {len(self.tags)}") print(f"Categories: {len(self.categories)}")