Skip to content

Commit 0311164

Browse files
parshvadaftarithestumonkey
authored andcommitted
Fix dependency and tests and updated docstring (mem0ai#3337)
1 parent 2b789b8 commit 0311164

File tree

6 files changed

+53
-22
lines changed

6 files changed

+53
-22
lines changed

mem0/client/main.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,17 @@ def update(
265265
) -> Dict[str, Any]:
266266
"""
267267
Update a memory by ID.
268+
268269
Args:
269270
memory_id (str): Memory ID.
270-
text (str, optional): Data to update in the memory.
271+
text (str, optional): New content to update the memory with.
271272
metadata (dict, optional): Metadata to update in the memory.
273+
272274
Returns:
273275
Dict[str, Any]: The response from the server.
276+
277+
Example:
278+
>>> client.update(memory_id="mem_123", text="Likes to play tennis on weekends")
274279
"""
275280
if text is None and metadata is None:
276281
raise ValueError("Either text or metadata must be provided for update.")
@@ -1054,13 +1059,18 @@ async def update(
10541059
self, memory_id: str, text: Optional[str] = None, metadata: Optional[Dict[str, Any]] = None
10551060
) -> Dict[str, Any]:
10561061
"""
1057-
Update a memory by ID.
1062+
Update a memory by ID asynchronously.
1063+
10581064
Args:
10591065
memory_id (str): Memory ID.
1060-
text (str, optional): Data to update in the memory.
1066+
text (str, optional): New content to update the memory with.
10611067
metadata (dict, optional): Metadata to update in the memory.
1068+
10621069
Returns:
10631070
Dict[str, Any]: The response from the server.
1071+
1072+
Example:
1073+
>>> await client.update(memory_id="mem_123", text="Likes to play tennis on weekends")
10641074
"""
10651075
if text is None and metadata is None:
10661076
raise ValueError("Either text or metadata must be provided for update.")

mem0/memory/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ def update(self, memory_id, data):
3232
3333
Args:
3434
memory_id (str): ID of the memory to update.
35-
data (dict): Data to update the memory with.
35+
data (str): New content to update the memory with.
3636
3737
Returns:
38-
dict: Updated memory.
38+
dict: Success message indicating the memory was updated.
3939
"""
4040
pass
4141

mem0/memory/main.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,14 @@ def update(self, memory_id, data):
730730
731731
Args:
732732
memory_id (str): ID of the memory to update.
733-
data (dict): Data to update the memory with.
733+
data (str): New content to update the memory with.
734734
735735
Returns:
736-
dict: Updated memory.
736+
dict: Success message indicating the memory was updated.
737+
738+
Example:
739+
>>> m.update(memory_id="mem_123", data="Likes to play tennis on weekends")
740+
{'message': 'Memory updated successfully!'}
737741
"""
738742
capture_event("mem0.update", self, {"memory_id": memory_id, "sync_type": "sync"})
739743

@@ -994,6 +998,15 @@ def __init__(self, config: MemoryConfig = MemoryConfig()):
994998
else:
995999
self.graph = None
9961000

1001+
self.config.vector_store.config.collection_name = "mem0migrations"
1002+
if self.config.vector_store.provider in ["faiss", "qdrant"]:
1003+
provider_path = f"migrations_{self.config.vector_store.provider}"
1004+
self.config.vector_store.config.path = os.path.join(mem0_dir, provider_path)
1005+
os.makedirs(self.config.vector_store.config.path, exist_ok=True)
1006+
self._telemetry_vector_store = VectorStoreFactory.create(
1007+
self.config.vector_store.provider, self.config.vector_store.config
1008+
)
1009+
9971010
capture_event("mem0.init", self, {"sync_type": "async"})
9981011

9991012
@classmethod
@@ -1580,10 +1593,14 @@ async def update(self, memory_id, data):
15801593
15811594
Args:
15821595
memory_id (str): ID of the memory to update.
1583-
data (dict): Data to update the memory with.
1596+
data (str): New content to update the memory with.
15841597
15851598
Returns:
1586-
dict: Updated memory.
1599+
dict: Success message indicating the memory was updated.
1600+
1601+
Example:
1602+
>>> await m.update(memory_id="mem_123", data="Likes to play tennis on weekends")
1603+
{'message': 'Memory updated successfully!'}
15871604
"""
15881605
capture_event("mem0.update", self, {"memory_id": memory_id, "sync_type": "async"})
15891606

mem0/proxy/main.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@
1111
try:
1212
import litellm
1313
except ImportError:
14-
user_input = input("The 'litellm' library is required. Install it now? [y/N]: ")
15-
if user_input.lower() == "y":
16-
try:
17-
subprocess.check_call([sys.executable, "-m", "pip", "install", "litellm"])
18-
import litellm
19-
except subprocess.CalledProcessError:
20-
print("Failed to install 'litellm'. Please install it manually using 'pip install litellm'.")
21-
sys.exit(1)
22-
else:
23-
raise ImportError("The required 'litellm' library is not installed.")
14+
try:
15+
subprocess.check_call([sys.executable, "-m", "pip", "install", "litellm"])
16+
import litellm
17+
except subprocess.CalledProcessError:
18+
print("Failed to install 'litellm'. Please install it manually using 'pip install litellm'.")
2419
sys.exit(1)
2520

2621
from mem0 import Memory, MemoryClient

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ requires-python = ">=3.9,<4.0"
1414
dependencies = [
1515
"qdrant-client>=1.9.1",
1616
"pydantic>=2.7.3",
17-
"openai>=1.33.0",
17+
"openai>=1.90.0,<1.100.0",
1818
"posthog>=3.5.0",
1919
"pytz>=2024.1",
2020
"sqlalchemy>=2.0.31",
@@ -46,7 +46,8 @@ vector_stores = [
4646
llms = [
4747
"groq>=0.3.0",
4848
"together>=0.2.10",
49-
"litellm>=0.1.0",
49+
"litellm>=1.74.0",
50+
"openai>=1.90.0,<1.100.0",
5051
"ollama>=0.1.0",
5152
"vertexai>=0.1.0",
5253
"google-generativeai>=0.3.0",

server/main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,15 @@ def search_memories(search_req: SearchRequest):
151151

152152
@app.put("/memories/{memory_id}", summary="Update a memory")
153153
def update_memory(memory_id: str, updated_memory: Dict[str, Any]):
154-
"""Update an existing memory."""
154+
"""Update an existing memory with new content.
155+
156+
Args:
157+
memory_id (str): ID of the memory to update
158+
updated_memory (str): New content to update the memory with
159+
160+
Returns:
161+
dict: Success message indicating the memory was updated
162+
"""
155163
try:
156164
return MEMORY_INSTANCE.update(memory_id=memory_id, data=updated_memory)
157165
except Exception as e:

0 commit comments

Comments
 (0)