mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-07 23:28:30 +00:00
* ensure original embedding config works * some fixes * raise error on unsupported provider * WIP: brandons notes * fixes * rm prints * fixed docs * fixed run types * updates to add more docs and correct imports with huggingface embedding server enabled --------- Co-authored-by: Brandon Hancock <brandon@brandonhancock.io>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from crewai.memory.entity.entity_memory_item import EntityMemoryItem
|
|
from crewai.memory.memory import Memory
|
|
from crewai.memory.storage.rag_storage import RAGStorage
|
|
|
|
|
|
class EntityMemory(Memory):
|
|
"""
|
|
EntityMemory class for managing structured information about entities
|
|
and their relationships using SQLite storage.
|
|
Inherits from the Memory class.
|
|
"""
|
|
|
|
def __init__(self, crew=None, embedder_config=None, storage=None):
|
|
storage = (
|
|
storage
|
|
if storage
|
|
else RAGStorage(
|
|
type="entities",
|
|
allow_reset=True,
|
|
embedder_config=embedder_config,
|
|
crew=crew,
|
|
)
|
|
)
|
|
super().__init__(storage)
|
|
|
|
def save(self, item: EntityMemoryItem) -> None: # type: ignore # BUG?: Signature of "save" incompatible with supertype "Memory"
|
|
"""Saves an entity item into the SQLite storage."""
|
|
data = f"{item.name}({item.type}): {item.description}"
|
|
super().save(data, item.metadata)
|
|
|
|
def reset(self) -> None:
|
|
try:
|
|
self.storage.reset()
|
|
except Exception as e:
|
|
raise Exception(f"An error occurred while resetting the entity memory: {e}")
|