Repository: mem0ai/mem0
File: mem0/client/main.py (Python)

Code before:
    @api_error_handler
    async def get_custom_instructions_and_categories(self, custom_instructions: Optional[bool]=False, custom_categories: Optional[bool]=False) -> Dict[str, Any]:
        if not (self.sync_client.org_id and self.sync_client.project_id):
            raise ValueError("org_id and project_id must be set to access instructions or categories")

        if not custom_instructions and not custom_categories:
            return {}

        fields = []
        if custom_instructions:
            fields.append("custom_instructions")
        if custom_categories:
            fields.append("custom_categories")
        params = self._prepare_params({"fields": fields})
        response = await self.async_client.get(
            f"/api/v1/orgs/organizations/{self.sync_client.org_id}/projects/{self.sync_client.project_id}/",
            params=params,
        )
        response.raise_for_status()
        capture_client_event(
            "async_client.get_custom_instructions_and_categories", self.sync_client, {"custom_instructions": custom_instructions, "custom_categories": custom_categories}
        )
        return response.json()

    @api_error_handler
    async def update_custom_instructions_and_categories(self, custom_instructions: Optional[str], custom_categories: Optional[List[str]]) -> Dict[str, Any]:
        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")

        if custom_instructions is None and custom_categories is None:
            raise ValueError("Either custom_instructions or custom_categories must be provided")

        payload = self.sync_client._prepare_params({"custom_instructions": custom_instructions, "custom_categories": custom_categories})
        response = await self.async_client.patch(
            f"/api/v1/orgs/organizations/{self.sync_client.org_id}/projects/{self.sync_client.project_id}/",
            json=payload,
        )
        response.raise_for_status()
        capture_client_event(
            "async_client.update_custom_instructions_and_categories", self.sync_client, {"custom_instructions": custom_instructions, "custom_categories": custom_categories}
        )
        return response.json()

    async def chat(self):
        raise NotImplementedError("Chat is not implemented yet")


Review comment (suggestion):
Same. This function should not exist at all. Updating the custom instructions and categories are tied to the project so we should have a new API `update project` and it should take care of updating the custom instructions and categories. Please let me know if there are any questions. 

Code after:
    @api_error_handler
    async def get_project(self, fields: Optional[List[str]]=None) -> Dict[str, Any]:
        if not (self.sync_client.org_id and self.sync_client.project_id):
            raise ValueError("org_id and project_id must be set to access instructions or categories")


        params = self._prepare_params({"fields": fields})
        response = await self.async_client.get(
            f"/api/v1/orgs/organizations/{self.sync_client.org_id}/projects/{self.sync_client.project_id}/",
            params=params,
        )
        response.raise_for_status()
        capture_client_event(
            "async_client.get_project", self.sync_client, {"fields": fields}
        )
        return response.json()

    @api_error_handler
    async def update_project(self, custom_instructions: Optional[str], custom_categories: Optional[List[str]]) -> Dict[str, Any]:
        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")

        payload = self.sync_client._prepare_params({"custom_instructions": custom_instructions, "custom_categories": custom_categories})
        response = await self.async_client.patch(
            f"/api/v1/orgs/organizations/{self.sync_client.org_id}/projects/{self.sync_client.project_id}/",
            json=payload,
        )
        response.raise_for_status()
        capture_client_event(
            "async_client.update_project", self.sync_client, {"custom_instructions": custom_instructions, "custom_categories": custom_categories}
        )
        return response.json()

    async def chat(self):
        raise NotImplementedError("Chat is not implemented yet")