mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-07 23:28:30 +00:00
* clean up. fix type safety. address memory config docs * improve manager * Include fix for o1 models not supporting system messages * more broad with o1 * address fix: Typo in expected_output string #2045 * drop prints * drop prints * wip * wip * fix failing memory tests * Fix memory provider issue * clean up short term memory * revert ltm * drop * clean up linting issues * more linting
39 lines
905 B
Python
39 lines
905 B
Python
from typing import Any, Dict, List, Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class Memory(BaseModel):
|
|
"""
|
|
Base class for memory, now supporting agent tags and generic metadata.
|
|
"""
|
|
|
|
embedder_config: Optional[Dict[str, Any]] = None
|
|
|
|
storage: Any
|
|
|
|
def __init__(self, storage: Any, **data: Any):
|
|
super().__init__(storage=storage, **data)
|
|
|
|
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
|
|
)
|