mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
* byom - short/entity memory * better * rm uneeded * fix text * use context * rm dep and sync * type check fix * fixed test using new cassete * fixing types * fixed types * fix types * fixed types * fixing types * fix type * cassette update * just mock the return of short term mem * remove print * try catch block * added docs * dding error handling here
28 lines
674 B
Python
28 lines
674 B
Python
from typing import Any, Dict, Optional, List
|
|
|
|
from crewai.memory.storage.rag_storage import RAGStorage
|
|
|
|
|
|
class Memory:
|
|
"""
|
|
Base class for memory, now supporting agent tags and generic metadata.
|
|
"""
|
|
|
|
def __init__(self, storage: RAGStorage):
|
|
self.storage = storage
|
|
|
|
def save(
|
|
self,
|
|
value: Any,
|
|
metadata: Optional[Dict[str, Any]] = None,
|
|
agent: Optional[str] = None,
|
|
) -> None:
|
|
metadata = metadata or {}
|
|
if agent:
|
|
metadata["agent"] = agent
|
|
|
|
self.storage.save(value, metadata)
|
|
|
|
def search(self, query: str) -> List[Dict[str, Any]]:
|
|
return self.storage.search(query)
|