mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-07 23:28:30 +00:00
* sort imports * update --------- Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com> Co-authored-by: Eduardo Chiarotti <dudumelgaco@hotmail.com>
35 lines
823 B
Python
35 lines
823 B
Python
from typing import Any, Dict, List, Optional
|
|
|
|
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,
|
|
limit: int = 3,
|
|
score_threshold: float = 0.35,
|
|
) -> List[Any]:
|
|
return self.storage.search(
|
|
query=query, limit=limit, score_threshold=score_threshold
|
|
)
|