mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-20 21:38:14 +00:00
Fix Mem0 OSS (#2604)
* Fix Mem0 OSS * add test * fix lint and tests * fix * add tests * drop test * changed to class comparision * fixed test cases * Update src/crewai/memory/storage/mem0_storage.py * Update src/crewai/memory/storage/mem0_storage.py * fix * fix lock file --------- Co-authored-by: Vidit-Ostwal <viditostwal@gmail.com>
This commit is contained in:
@@ -88,7 +88,9 @@ class Mem0Storage(Storage):
|
||||
}
|
||||
|
||||
if params:
|
||||
self.memory.add(value, **params | {"output_format": "v1.1"})
|
||||
if isinstance(self.memory, MemoryClient):
|
||||
params["output_format"] = "v1.1"
|
||||
self.memory.add(value, **params)
|
||||
|
||||
def search(
|
||||
self,
|
||||
@@ -96,7 +98,7 @@ class Mem0Storage(Storage):
|
||||
limit: int = 3,
|
||||
score_threshold: float = 0.35,
|
||||
) -> List[Any]:
|
||||
params = {"query": query, "limit": limit}
|
||||
params = {"query": query, "limit": limit, "output_format": "v1.1"}
|
||||
if user_id := self._get_user_id():
|
||||
params["user_id"] = user_id
|
||||
|
||||
@@ -116,8 +118,11 @@ class Mem0Storage(Storage):
|
||||
|
||||
# Discard the filters for now since we create the filters
|
||||
# automatically when the crew is created.
|
||||
if isinstance(self.memory, Memory):
|
||||
del params["metadata"], params["output_format"]
|
||||
|
||||
results = self.memory.search(**params)
|
||||
return [r for r in results if r["score"] >= score_threshold]
|
||||
return [r for r in results["results"] if r["score"] >= score_threshold]
|
||||
|
||||
def _get_user_id(self) -> str:
|
||||
return self._get_config().get("user_id", "")
|
||||
|
||||
Reference in New Issue
Block a user