|
|
|
@ -21,6 +21,8 @@ logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BaseEntityStore(BaseModel, ABC):
|
|
|
|
|
"""Abstract base class for Entity store."""
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get(self, key: str, default: Optional[str] = None) -> Optional[str]:
|
|
|
|
|
"""Get entity value from store."""
|
|
|
|
@ -48,7 +50,7 @@ class BaseEntityStore(BaseModel, ABC):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InMemoryEntityStore(BaseEntityStore):
|
|
|
|
|
"""Basic in-memory entity store."""
|
|
|
|
|
"""In-memory Entity store."""
|
|
|
|
|
|
|
|
|
|
store: Dict[str, Optional[str]] = {}
|
|
|
|
|
|
|
|
|
@ -69,7 +71,9 @@ class InMemoryEntityStore(BaseEntityStore):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RedisEntityStore(BaseEntityStore):
|
|
|
|
|
"""Redis-backed Entity store. Entities get a TTL of 1 day by default, and
|
|
|
|
|
"""Redis-backed Entity store.
|
|
|
|
|
|
|
|
|
|
Entities get a TTL of 1 day by default, and
|
|
|
|
|
that TTL is extended by 3 days every time the entity is read back.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
@ -245,7 +249,7 @@ class ConversationEntityMemory(BaseChatMemory):
|
|
|
|
|
"""Entity extractor & summarizer memory.
|
|
|
|
|
|
|
|
|
|
Extracts named entities from the recent chat history and generates summaries.
|
|
|
|
|
With a swapable entity store, persisting entities across conversations.
|
|
|
|
|
With a swappable entity store, persisting entities across conversations.
|
|
|
|
|
Defaults to an in-memory entity store, and can be swapped out for a Redis,
|
|
|
|
|
SQLite, or other entity store.
|
|
|
|
|
"""
|
|
|
|
|