From dd06333732d652388d8f9c5f56afb6f9955552d6 Mon Sep 17 00:00:00 2001 From: Dev Khant Date: Thu, 28 Nov 2024 17:06:05 +0530 Subject: [PATCH] Doc update (#2065) --- docs/api-reference/memory/batch-delete.mdx | 4 + docs/api-reference/memory/batch-update.mdx | 4 + docs/mint.json | 4 +- docs/openapi.json | 166 +++++++++++++++++++++ docs/platform/quickstart.mdx | 97 ++++++++++++ 5 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 docs/api-reference/memory/batch-delete.mdx create mode 100644 docs/api-reference/memory/batch-update.mdx diff --git a/docs/api-reference/memory/batch-delete.mdx b/docs/api-reference/memory/batch-delete.mdx new file mode 100644 index 00000000..34491854 --- /dev/null +++ b/docs/api-reference/memory/batch-delete.mdx @@ -0,0 +1,4 @@ +--- +title: 'Batch Delete Memories' +openapi: delete /v1/memories/batch/ +--- diff --git a/docs/api-reference/memory/batch-update.mdx b/docs/api-reference/memory/batch-update.mdx new file mode 100644 index 00000000..8223766f --- /dev/null +++ b/docs/api-reference/memory/batch-update.mdx @@ -0,0 +1,4 @@ +--- +title: 'Batch Update Memories' +openapi: put /v1/memories/batch/ +--- \ No newline at end of file diff --git a/docs/mint.json b/docs/mint.json index 76f2bf94..6cfbefb9 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -158,7 +158,9 @@ "api-reference/memory/delete-memory", "api-reference/memory/v1-search-memories", "api-reference/memory/v2-search-memories", - "api-reference/memory/history-memory" + "api-reference/memory/history-memory", + "api-reference/memory/batch-update", + "api-reference/memory/batch-delete" ] }, { diff --git a/docs/openapi.json b/docs/openapi.json index a51e0593..31693430 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -3579,6 +3579,172 @@ } ] } + }, + "/v1/memories/batch/": { + "put": { + "tags": [ + "memories" + ], + "description": "Batch update multiple memories (up to 1000) in a single API call.", + "operationId": "memories_batch_update", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "memories": { + "type": "array", + "items": { + "type": "object", + "required": ["memory_id", "text"], + "properties": { + "memory_id": { + "type": "string", + "format": "uuid", + "description": "The unique identifier of the memory to update" + }, + "text": { + "type": "string", + "description": "The new text content for the memory" + } + } + }, + "maxItems": 1000 + } + }, + "required": ["memories"] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successfully updated memories", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string", + "example": "Successfully updated 2 memories" + } + } + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "Maximum of 1000 memories can be updated in a single request" + } + } + } + } + } + } + }, + "x-code-samples": [ + { + "lang": "Python", + "source": "# To use the Python SDK, install the package:\n# pip install mem0ai\n\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"your-api-key\")\n\nupdate_memories = [\n {\n \"memory_id\": \"285ed74b-6e05-4043-b16b-3abd5b533496\",\n \"text\": \"Watches football\"\n },\n {\n \"memory_id\": \"2c9bd859-d1b7-4d33-a6b8-94e0147c4f07\",\n \"text\": \"Likes to travel\"\n }\n]\n\nresponse = client.batch_update(update_memories)\nprint(response)" + }, + { + "lang": "JavaScript", + "source": "// To use the JavaScript SDK, install the package:\n// npm i mem0ai\n\nimport MemoryClient from 'mem0ai';\nconst client = new MemoryClient({ apiKey: \"your-api-key\" });\n\nconst updateMemories = [\n {\n memoryId: \"285ed74b-6e05-4043-b16b-3abd5b533496\",\n text: \"Watches football\"\n },\n {\n memoryId: \"2c9bd859-d1b7-4d33-a6b8-94e0147c4f07\",\n text: \"Likes to travel\"\n }\n];\n\nclient.batchUpdate(updateMemories)\n .then(response => console.log('Batch update response:', response))\n .catch(error => console.error(error));" + }, + { + "lang": "cURL", + "source": "curl -X PUT \"https://api.mem0.ai/v1/memories/batch/\" \\\n -H \"Authorization: Token your-api-key\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"memories\": [\n {\n \"memory_id\": \"285ed74b-6e05-4043-b16b-3abd5b533496\",\n \"text\": \"Watches football\"\n },\n {\n \"memory_id\": \"2c9bd859-d1b7-4d33-a6b8-94e0147c4f07\",\n \"text\": \"Likes to travel\"\n }\n ]\n }'" + } + ] + }, + "delete": { + "tags": [ + "memories" + ], + "description": "Batch delete multiple memories (up to 1000) in a single API call.", + "operationId": "memories_batch_delete", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "memory_ids": { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + }, + "maxItems": 1000, + "description": "Array of memory IDs to delete" + } + }, + "required": ["memory_ids"] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successfully deleted memories", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string", + "example": "Successfully deleted 2 memories" + } + } + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "Maximum of 1000 memories can be deleted in a single request" + } + } + } + } + } + } + }, + "x-code-samples": [ + { + "lang": "Python", + "source": "# To use the Python SDK, install the package:\n# pip install mem0ai\n\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"your-api-key\")\n\ndelete_memories = [\n \"285ed74b-6e05-4043-b16b-3abd5b533496\",\n \"2c9bd859-d1b7-4d33-a6b8-94e0147c4f07\"\n]\n\nresponse = client.batch_delete(delete_memories)\nprint(response)" + }, + { + "lang": "JavaScript", + "source": "// To use the JavaScript SDK, install the package:\n// npm i mem0ai\n\nimport MemoryClient from 'mem0ai';\nconst client = new MemoryClient({ apiKey: \"your-api-key\" });\n\nconst deleteMemories = [\n \"285ed74b-6e05-4043-b16b-3abd5b533496\",\n \"2c9bd859-d1b7-4d33-a6b8-94e0147c4f07\"\n];\n\nclient.batchDelete(deleteMemories)\n .then(response => console.log('Batch delete response:', response))\n .catch(error => console.error(error));" + }, + { + "lang": "cURL", + "source": "curl -X DELETE \"https://api.mem0.ai/v1/memories/batch/\" \\\n -H \"Authorization: Token your-api-key\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"memory_ids\": [\n \"285ed74b-6e05-4043-b16b-3abd5b533496\",\n \"2c9bd859-d1b7-4d33-a6b8-94e0147c4f07\"\n ]\n }'" + } + ] + } } }, "components": { diff --git a/docs/platform/quickstart.mdx b/docs/platform/quickstart.mdx index e9078d0a..6c71d9f1 100644 --- a/docs/platform/quickstart.mdx +++ b/docs/platform/quickstart.mdx @@ -1508,6 +1508,103 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \ +### 4.9 Batch Update Memories +Update multiple memories in a single API call. You can update up to 1000 memories at once. + +```python Python +update_memories = [ + { + "memory_id": "285ed74b-6e05-4043-b16b-3abd5b533496", + "text": "Watches football" + }, + { + "memory_id": "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07", + "text": "Loves to travel" + } +] + +response = client.batch_update(update_memories) +print(response) +``` +```javascript JavaScript +const updateMemories = [ + { + memoryId: "285ed74b-6e05-4043-b16b-3abd5b533496", + text: "Watches football" + }, + { + memoryId: "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07", + text: "Loves to travel" + } +]; + +client.batchUpdate(updateMemories) + .then(response => console.log('Batch update response:', response)) + .catch(error => console.error(error)); +``` +```bash cURL +curl -X PUT "https://api.mem0.ai/v1/memories/batch/" \ + -H "Authorization: Token your-api-key" \ + -H "Content-Type: application/json" \ + -d '{ + "memories": [ + { + "memory_id": "285ed74b-6e05-4043-b16b-3abd5b533496", + "text": "Watches football" + }, + { + "memory_id": "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07", + "text": "Loves to travel" + } + ] + }' +``` +```json Output +{ + "message": "Successfully updated 2 memories" +} +``` + +### 4.10 Batch Delete Memories +Delete multiple memories in a single API call. You can delete up to 1000 memories at once. + +```python Python +delete_memories = [ + "285ed74b-6e05-4043-b16b-3abd5b533496", + "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07" +] + +response = client.batch_delete(delete_memories) +print(response) +``` +```javascript JavaScript +const deleteMemories = [ + "285ed74b-6e05-4043-b16b-3abd5b533496", + "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07" +]; + +client.batchDelete(deleteMemories) + .then(response => console.log('Batch delete response:', response)) + .catch(error => console.error(error)); +``` +```bash cURL +curl -X DELETE "https://api.mem0.ai/v1/memories/batch/" \ + -H "Authorization: Token your-api-key" \ + -H "Content-Type: application/json" \ + -d '{ + "memory_ids": [ + "285ed74b-6e05-4043-b16b-3abd5b533496", + "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07" + ] + }' +``` +```json Output +{ + "message": "Successfully deleted 2 memories" +} +``` + + If you have any questions, please feel free to reach out to us using one of the following methods: \ No newline at end of file