Changes to client (#2562)

This commit is contained in:
Prateek Chhikara
2025-04-17 11:28:39 -07:00
committed by GitHub
parent 8bd0d2dc24
commit 78912928bc
2 changed files with 15 additions and 11 deletions

View File

@@ -485,7 +485,10 @@ class MemoryClient:
@api_error_handler @api_error_handler
def update_project( def update_project(
self, custom_instructions: Optional[str] = None, custom_categories: Optional[List[str]] = None self,
custom_instructions: Optional[str] = None,
custom_categories: Optional[List[str]] = None,
retrieval_criteria: Optional[List[Dict[str, Any]]] = None,
) -> Dict[str, Any]: ) -> Dict[str, Any]:
"""Update the project settings. """Update the project settings.
@@ -503,13 +506,13 @@ class MemoryClient:
if not (self.org_id and self.project_id): if not (self.org_id and self.project_id):
raise ValueError("org_id and project_id must be set to update instructions or categories") raise ValueError("org_id and project_id must be set to update instructions or categories")
if custom_instructions is None and custom_categories is None: if custom_instructions is None and custom_categories is None and retrieval_criteria is None:
raise ValueError( raise ValueError(
"Currently we only support updating custom_instructions or custom_categories, so you must provide at least one of them" "Currently we only support updating custom_instructions or custom_categories or retrieval_criteria, so you must provide at least one of them"
) )
payload = self._prepare_params( payload = self._prepare_params(
{"custom_instructions": custom_instructions, "custom_categories": custom_categories} {"custom_instructions": custom_instructions, "custom_categories": custom_categories, "retrieval_criteria": retrieval_criteria}
) )
response = self.client.patch( response = self.client.patch(
f"/api/v1/orgs/organizations/{self.org_id}/projects/{self.project_id}/", f"/api/v1/orgs/organizations/{self.org_id}/projects/{self.project_id}/",
@@ -519,7 +522,7 @@ class MemoryClient:
capture_client_event( capture_client_event(
"client.update_project", "client.update_project",
self, self,
{"custom_instructions": custom_instructions, "custom_categories": custom_categories, "sync_type": "sync"}, {"custom_instructions": custom_instructions, "custom_categories": custom_categories, "retrieval_criteria": retrieval_criteria, "sync_type": "sync"},
) )
return response.json() return response.json()
@@ -955,18 +958,19 @@ class AsyncMemoryClient:
@api_error_handler @api_error_handler
async def update_project( async def update_project(
self, custom_instructions: Optional[str] = None, custom_categories: Optional[List[str]] = None self, custom_instructions: Optional[str] = None, custom_categories: Optional[List[str]] = None,
retrieval_criteria: Optional[List[Dict[str, Any]]] = None
) -> Dict[str, Any]: ) -> Dict[str, Any]:
if not (self.sync_client.org_id and self.sync_client.project_id): if not (self.sync_client.org_id and self.sync_client.project_id):
raise ValueError("org_id and project_id must be set to update instructions or categories") raise ValueError("org_id and project_id must be set to update instructions or categories")
if custom_instructions is None and custom_categories is None: if custom_instructions is None and custom_categories is None and retrieval_criteria is None:
raise ValueError( raise ValueError(
"Currently we only support updating custom_instructions or custom_categories, so you must provide at least one of them" "Currently we only support updating custom_instructions or custom_categories or retrieval_criteria, so you must provide at least one of them"
) )
payload = self.sync_client._prepare_params( payload = self.sync_client._prepare_params(
{"custom_instructions": custom_instructions, "custom_categories": custom_categories} {"custom_instructions": custom_instructions, "custom_categories": custom_categories, "retrieval_criteria": retrieval_criteria}
) )
response = await self.async_client.patch( response = await self.async_client.patch(
f"/api/v1/orgs/organizations/{self.sync_client.org_id}/projects/{self.sync_client.project_id}/", f"/api/v1/orgs/organizations/{self.sync_client.org_id}/projects/{self.sync_client.project_id}/",
@@ -976,7 +980,7 @@ class AsyncMemoryClient:
capture_client_event( capture_client_event(
"client.update_project", "client.update_project",
self.sync_client, self.sync_client,
{"custom_instructions": custom_instructions, "custom_categories": custom_categories, "sync_type": "async"}, {"custom_instructions": custom_instructions, "custom_categories": custom_categories, "retrieval_criteria": retrieval_criteria, "sync_type": "async"},
) )
return response.json() return response.json()

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "mem0ai" name = "mem0ai"
version = "0.1.91" version = "0.1.92"
description = "Long-term memory for AI Agents" description = "Long-term memory for AI Agents"
authors = ["Mem0 <founders@mem0.ai>"] authors = ["Mem0 <founders@mem0.ai>"]
exclude = [ exclude = [