diff --git a/apps/docs/add-memories.mdx b/apps/docs/add-memories.mdx index f10f51a1..65299249 100644 --- a/apps/docs/add-memories.mdx +++ b/apps/docs/add-memories.mdx @@ -116,7 +116,7 @@ To completely replace a document's content (not append), use `memories.update()` ```typescript // Replace the entire document content -await client.memories.update("doc_id_123", { +await client.documents.update("doc_id_123", { content: "Completely new content replacing everything", metadata: { version: 2 } }); @@ -153,7 +153,7 @@ Upload PDFs, images, and documents directly. ```typescript import fs from 'fs'; - await client.memories.uploadFile({ + await client.documents.uploadFile({ file: fs.createReadStream('document.pdf'), containerTags: 'user_123' }); @@ -162,7 +162,7 @@ Upload PDFs, images, and documents directly. ```python with open('document.pdf', 'rb') as file: - client.memories.upload_file( + client.documents.upload_file( file=file, container_tags='user_123' ) @@ -275,7 +275,7 @@ When you add content, Supermemory: Track progress with `GET /v3/documents/{id}`: ```typescript -const doc = await client.memories.get("abc123"); +const doc = await client.documents.get("abc123"); console.log(doc.status); // "queued" | "processing" | "done" ``` @@ -342,12 +342,12 @@ console.log(doc.status); // "queued" | "processing" | "done" **Single delete:** ```typescript - await client.memories.delete("doc_id_123"); + await client.documents.delete("doc_id_123"); ``` **Bulk delete by IDs:** ```typescript - await client.memories.bulkDelete({ + await client.documents.deleteBulk({ ids: ["doc_1", "doc_2", "doc_3"] }); ``` @@ -355,7 +355,7 @@ console.log(doc.status); // "queued" | "processing" | "done" **Bulk delete by container tag:** ```typescript // Delete all content for a user - await client.memories.bulkDelete({ + await client.documents.deleteBulk({ containerTags: ["user_123"] }); ``` diff --git a/apps/docs/add-memories/examples/file-upload.mdx b/apps/docs/add-memories/examples/file-upload.mdx index b07a44b6..7d79d36e 100644 --- a/apps/docs/add-memories/examples/file-upload.mdx +++ b/apps/docs/add-memories/examples/file-upload.mdx @@ -14,7 +14,7 @@ Extract text from PDFs with OCR support. ```typescript TypeScript const file = fs.createReadStream('document.pdf'); -const response = await client.memories.uploadFile({ +const response = await client.documents.uploadFile({ file: file, containerTags: 'documents' }); @@ -25,7 +25,7 @@ console.log(response.id); ```python Python with open('document.pdf', 'rb') as file: - response = client.memories.upload_file( + response = client.documents.upload_file( file=file, container_tags='documents' ) @@ -54,7 +54,7 @@ Extract text from images. ```typescript TypeScript const image = fs.createReadStream('screenshot.png'); -await client.memories.uploadFile({ +await client.documents.uploadFile({ file: image, containerTags: 'images' }); @@ -62,7 +62,7 @@ await client.memories.uploadFile({ ```python Python with open('screenshot.png', 'rb') as file: - client.memories.upload_file( + client.documents.upload_file( file=file, container_tags='images' ) @@ -134,7 +134,7 @@ Batch upload with rate limiting. for (const file of files) { const stream = fs.createReadStream(file); - await client.memories.uploadFile({ + await client.documents.uploadFile({ file: stream, containerTags: 'batch' }); @@ -149,7 +149,7 @@ import time for file_path in files: with open(file_path, 'rb') as file: - client.memories.upload_file( + client.documents.upload_file( file=file, container_tags='batch' ) diff --git a/apps/docs/add-memories/overview.mdx b/apps/docs/add-memories/overview.mdx index 95031f30..5b07381b 100644 --- a/apps/docs/add-memories/overview.mdx +++ b/apps/docs/add-memories/overview.mdx @@ -156,14 +156,14 @@ Upload files directly for processing. ```typescript TypeScript -await client.memories.uploadFile({ +await client.documents.uploadFile({ file: fileStream, containerTag: "project" }); ``` ```python Python -client.memories.upload_file( +client.documents.upload_file( file=open('file.pdf', 'rb'), container_tags='project' ) @@ -187,13 +187,13 @@ Update existing document content. ```typescript TypeScript -await client.memories.update("doc_id", { +await client.documents.update("doc_id", { content: "Updated content" }); ``` ```python Python -client.memories.update("doc_id", { +client.documents.update("doc_id", { "content": "Updated content" }) ``` diff --git a/apps/docs/concepts/memory-vs-rag.mdx b/apps/docs/concepts/memory-vs-rag.mdx index 729355b6..bee60d43 100644 --- a/apps/docs/concepts/memory-vs-rag.mdx +++ b/apps/docs/concepts/memory-vs-rag.mdx @@ -216,7 +216,7 @@ client.add( ### 3. Hybrid Retrieval ```python # Search combines both approaches -results = client.memories.search( +results = client.documents.search( query="What phone should I recommend?", container_tags=["user_123"], # Gets user memories # Also searches general knowledge diff --git a/apps/docs/connectors/overview.mdx b/apps/docs/connectors/overview.mdx index f36c39ad..cb4ca1eb 100644 --- a/apps/docs/connectors/overview.mdx +++ b/apps/docs/connectors/overview.mdx @@ -139,7 +139,7 @@ connections.forEach(conn => { }); // List synced documents (memories) using SDK -const memories = await client.memories.list({ +const memories = await client.documents.list({ containerTags: ['user-123', 'workspace-alpha'] }); @@ -165,7 +165,7 @@ for conn in connections: print(f'Created: {conn.created_at}') # List synced documents (memories) using SDK -memories = client.memories.list(container_tags=['user-123', 'workspace-alpha']) +memories = client.documents.list(container_tags=['user-123', 'workspace-alpha']) print(f'Synced {len(memories.memories)} documents') # Output: Synced 45 documents diff --git a/apps/docs/cookbook/customer-support.mdx b/apps/docs/cookbook/customer-support.mdx index b1643556..01ad0e8e 100644 --- a/apps/docs/cookbook/customer-support.mdx +++ b/apps/docs/cookbook/customer-support.mdx @@ -93,7 +93,7 @@ A customer support bot that: async getCustomerHistory(customerId: string, limit: number = 10) { try { - const memories = await client.memories.list({ + const memories = await client.documents.list({ containerTags: [this.getContainerTag(customerId)], limit, sort: 'updatedAt', @@ -170,8 +170,8 @@ A customer support bot that: try { // Note: In a real implementation, you'd update the memory // For now, we'll add a status update - const memory = await client.memories.get(issueId) - const customerId = memory.containerTag.replace('customer_', '') + const memory = await client.documents.get(issueId) + const customerId = memory.containerTags?.[0]?.replace('customer_', '') || '' const updateContent = `ISSUE UPDATE: ${memory.metadata?.subject}\nStatus changed to: ${status}${resolution ? `\nResolution: ${resolution}` : ''}` @@ -253,7 +253,7 @@ A customer support bot that: def get_customer_history(self, customer_id: str, limit: int = 10) -> List[Dict]: """Get customer interaction history""" try: - memories = self.client.memories.list( + memories = self.client.documents.list( container_tags=[self._get_container_tag(customer_id)], limit=limit, sort='updatedAt', @@ -330,8 +330,8 @@ Status: {issue['status']}""" """Update the status of a support issue""" try: # Get original issue - memory = self.client.memories.get(issue_id) - customer_id = memory.container_tag.replace('customer_', '') + memory = self.client.documents.get(issue_id) + customer_id = (memory.container_tags[0] if memory.container_tags else '').replace('customer_', '') update_content = f"ISSUE UPDATE: {memory.metadata.get('subject', 'Unknown')}\nStatus changed to: {status}" if resolution: diff --git a/apps/docs/cookbook/document-qa.mdx b/apps/docs/cookbook/document-qa.mdx index e18b7c2f..5aa071eb 100644 --- a/apps/docs/cookbook/document-qa.mdx +++ b/apps/docs/cookbook/document-qa.mdx @@ -91,7 +91,7 @@ A document Q&A system that: async getDocumentStatus(documentId: string) { try { - const memory = await client.memories.get(documentId) + const memory = await client.documents.get(documentId) return { id: memory.id, status: memory.status, @@ -106,7 +106,7 @@ A document Q&A system that: async listDocuments(collection: string) { try { - const memories = await client.memories.list({ + const memories = await client.documents.list({ containerTags: [collection], limit: 50, sort: 'updatedAt', @@ -148,15 +148,10 @@ A document Q&A system that: return NextResponse.json({ error: 'No file provided' }, { status: 400 }) } - // Convert File to Buffer for Supermemory - const bytes = await file.arrayBuffer() - const buffer = Buffer.from(bytes) - - const result = await client.memories.uploadFile({ - file: buffer, - filename: file.name, - containerTags, - metadata + const result = await client.documents.uploadFile({ + file: file, + containerTags: JSON.stringify(containerTags), + metadata: JSON.stringify(metadata) }) return NextResponse.json({ @@ -180,6 +175,7 @@ A document Q&A system that: ```python document_processor.py from supermemory import Supermemory import os + import json from typing import Dict, List, Any, Optional import requests from datetime import datetime @@ -195,15 +191,15 @@ A document Q&A system that: try: with open(file_path, 'rb') as file: - result = self.client.memories.upload_file( + result = self.client.documents.upload_file( file=file, - container_tags=[collection], - metadata={ + container_tags=collection, + metadata=json.dumps({ 'originalName': os.path.basename(file_path), 'fileType': os.path.splitext(file_path)[1], 'uploadedAt': datetime.now().isoformat(), **metadata - } + }) ) return result except Exception as e: @@ -234,7 +230,7 @@ A document Q&A system that: def get_document_status(self, document_id: str) -> Dict: """Check document processing status""" try: - memory = self.client.memories.get(document_id) + memory = self.client.documents.get(document_id) return { 'id': memory.id, 'status': memory.status, @@ -248,7 +244,7 @@ A document Q&A system that: def list_documents(self, collection: str) -> List[Dict]: """List all documents in a collection""" try: - memories = self.client.memories.list( + memories = self.client.documents.list( container_tags=[collection], limit=50, sort='updatedAt', @@ -307,7 +303,6 @@ A document Q&A system that: includeFullDocs: false, includeSummary: true, onlyMatchingChunks: false, - documentThreshold: 0.6, chunkThreshold: 0.7 }) @@ -432,7 +427,6 @@ If the question cannot be answered from the provided documents, respond with: "I include_full_docs=False, include_summary=True, only_matching_chunks=False, - document_threshold=0.6, chunk_threshold=0.7 ) diff --git a/apps/docs/cookbook/personal-assistant.mdx b/apps/docs/cookbook/personal-assistant.mdx index d4522590..c33f2e61 100644 --- a/apps/docs/cookbook/personal-assistant.mdx +++ b/apps/docs/cookbook/personal-assistant.mdx @@ -803,7 +803,7 @@ client = Supermemory(api_key=os.getenv("SUPERMEMORY_API_KEY")) user_id = "your_user_id_here" container_tag = f"user_{user_id}" -memories = client.memories.list( +memories = client.documents.list( container_tags=[container_tag], limit=20, sort="updatedAt", @@ -812,7 +812,7 @@ memories = client.memories.list( print(f"Found {len(memories.memories)} memories:") for i, memory in enumerate(memories.memories): - full = client.memories.get(id=memory.id) + full = client.documents.get(id=memory.id) print(f"\n{i + 1}. {full.content}") ``` diff --git a/apps/docs/document-operations.mdx b/apps/docs/document-operations.mdx index d0b88551..2161d696 100644 --- a/apps/docs/document-operations.mdx +++ b/apps/docs/document-operations.mdx @@ -19,7 +19,7 @@ Retrieve paginated documents with filtering. containerTags: ["user_123"] }); - documents.forEach(d => { + documents.memories.forEach(d => { console.log(d.id, d.title, d.status); }); ``` @@ -104,12 +104,12 @@ Retrieve paginated documents with filtering. ```typescript const documents = await client.documents.list({ containerTags: ["user_123"], - filters: JSON.stringify({ + filters: { AND: [ - { key: "status", value: "reviewed" }, - { key: "priority", value: "high" } + { key: "status", value: "reviewed", negate: false }, + { key: "priority", value: "high", negate: false } ] - }) + } }); ``` @@ -197,7 +197,7 @@ Update a document's content or metadata. Triggers reprocessing. ```bash - curl -X PUT "https://api.supermemory.ai/v3/documents/doc_abc123" \ + curl -X PATCH "https://api.supermemory.ai/v3/documents/doc_abc123" \ -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"content": "Updated content here", "metadata": {"version": 2}}' @@ -218,12 +218,12 @@ Permanently remove documents. await client.documents.delete("doc_abc123"); // Bulk delete by IDs - await client.documents.bulkDelete({ + await client.documents.deleteBulk({ ids: ["doc_1", "doc_2", "doc_3"] }); // Bulk delete by container tag (delete all for a user) - await client.documents.bulkDelete({ + await client.documents.deleteBulk({ containerTags: ["user_123"] }); ``` @@ -234,10 +234,10 @@ Permanently remove documents. client.documents.delete("doc_abc123") # Bulk delete by IDs - client.documents.bulk_delete(ids=["doc_1", "doc_2", "doc_3"]) + client.documents.delete_bulk(ids=["doc_1", "doc_2", "doc_3"]) # Bulk delete by container tag - client.documents.bulk_delete(container_tags=["user_123"]) + client.documents.delete_bulk(container_tags=["user_123"]) ``` @@ -247,7 +247,7 @@ Permanently remove documents. -H "Authorization: Bearer $SUPERMEMORY_API_KEY" # Bulk delete by IDs - curl -X POST "https://api.supermemory.ai/v3/documents/bulk-delete" \ + curl -X DELETE "https://api.supermemory.ai/v3/documents/bulk" \ -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"ids": ["doc_1", "doc_2", "doc_3"]}' @@ -268,12 +268,14 @@ Check documents currently being processed. ```typescript - const response = await fetch("https://api.supermemory.ai/v3/documents/processing", { - headers: { "Authorization": `Bearer ${API_KEY}` } - }); - - const { documents } = await response.json(); - console.log(`${documents.length} documents processing`); + const response = await client.documents.listProcessing(); + console.log(`${response.documents.length} documents processing`); + ``` + + + ```python + response = client.documents.list_processing() + print(f"{len(response.documents)} documents processing") ``` diff --git a/apps/docs/integrations/ai-sdk.mdx b/apps/docs/integrations/ai-sdk.mdx index f67c8508..4f70d916 100644 --- a/apps/docs/integrations/ai-sdk.mdx +++ b/apps/docs/integrations/ai-sdk.mdx @@ -150,16 +150,6 @@ const result = await streamText({ // AI will call: addMemory({ memory: "User is allergic to peanuts" }) ``` -**Fetch Memory** - Retrieve specific memory by ID: - -```typescript -const result = await streamText({ - model: openai("gpt-5"), - prompt: "Get the details of memory abc123", - tools: supermemoryTools("API_KEY") -}) -``` - ### Using Individual Tools For more control, import tools separately: @@ -167,8 +157,7 @@ For more control, import tools separately: ```typescript import { searchMemoriesTool, - addMemoryTool, - fetchMemoryTool + addMemoryTool } from "@supermemory/tools/ai-sdk" const result = await streamText({ @@ -189,8 +178,5 @@ const result = await streamText({ // addMemory result { success: true, memory: { id: "mem_123", ... } } - -// fetchMemory result -{ success: true, memory: { id: "mem_123", content: "...", ... } } ``` diff --git a/apps/docs/integrations/openai.mdx b/apps/docs/integrations/openai.mdx index b27f7fce..f2987b92 100644 --- a/apps/docs/integrations/openai.mdx +++ b/apps/docs/integrations/openai.mdx @@ -204,30 +204,6 @@ console.log(`Added memory with ID: ${addResult.memory.id}`) -### Fetch Memory - -Retrieve specific memory by ID: - - - -```python Python -# Fetch specific memory -result = await tools.fetch_memory( - memory_id="memory-id-here" -) -print(f"Memory content: {result.memory.content}") -``` - -```typescript JavaScript -// Fetch specific memory -const fetchResult = await tools.fetchMemory({ - memoryId: "memory-id-here" -}) -console.log(`Memory content: ${fetchResult.memory.content}`) -``` - - - ## Individual Tools Use tools separately for more granular control: @@ -237,31 +213,27 @@ Use tools separately for more granular control: ```python Python Individual Tools from supermemory_openai import ( create_search_memories_tool, - create_add_memory_tool, - create_fetch_memory_tool + create_add_memory_tool ) search_tool = create_search_memories_tool("your-api-key") add_tool = create_add_memory_tool("your-api-key") -fetch_tool = create_fetch_memory_tool("your-api-key") # Use individual tools in OpenAI function calling -tools_list = [search_tool, add_tool, fetch_tool] +tools_list = [search_tool, add_tool] ``` ```typescript JavaScript Individual Tools import { createSearchMemoriesTool, - createAddMemoryTool, - createFetchMemoryTool + createAddMemoryTool } from "@supermemory/tools/openai" const searchTool = createSearchMemoriesTool(process.env.SUPERMEMORY_API_KEY!) const addTool = createAddMemoryTool(process.env.SUPERMEMORY_API_KEY!) -const fetchTool = createFetchMemoryTool(process.env.SUPERMEMORY_API_KEY!) // Use individual tools -const toolDefinitions = [searchTool, addTool, fetchTool] +const toolDefinitions = [searchTool.definition, addTool.definition] ``` @@ -490,7 +462,6 @@ SupermemoryTools( - `get_tool_definitions()` - Get OpenAI function definitions - `search_memories(information_to_get, limit, include_full_docs)` - Search user memories - `add_memory(memory)` - Add new memory -- `fetch_memory(memory_id)` - Fetch specific memory by ID - `execute_tool_call(tool_call)` - Execute individual tool call #### `execute_memory_tool_calls` diff --git a/apps/docs/list-memories/examples/basic.mdx b/apps/docs/list-memories/examples/basic.mdx index c4358c44..e0fa40dc 100644 --- a/apps/docs/list-memories/examples/basic.mdx +++ b/apps/docs/list-memories/examples/basic.mdx @@ -16,7 +16,7 @@ Simple memory retrieval examples for getting started with the list memories endp apiKey: process.env.SUPERMEMORY_API_KEY! }); - const response = await client.memories.list({ limit: 10 }); + const response = await client.documents.list({ limit: 10 }); console.log(response); ``` @@ -26,7 +26,7 @@ Simple memory retrieval examples for getting started with the list memories endp import os client = Supermemory(api_key=os.environ.get("SUPERMEMORY_API_KEY")) - response = client.memories.list(limit=10) + response = client.documents.list(limit=10) print(response) ``` @@ -45,7 +45,7 @@ Simple memory retrieval examples for getting started with the list memories endp ```typescript - const response = await client.memories.list({ + const response = await client.documents.list({ containerTags: ["user_123"], limit: 20, sort: "updatedAt", @@ -57,7 +57,7 @@ Simple memory retrieval examples for getting started with the list memories endp ```python - response = client.memories.list( + response = client.documents.list( container_tags=["user_123"], limit=20, sort="updatedAt", diff --git a/apps/docs/list-memories/examples/filtering.mdx b/apps/docs/list-memories/examples/filtering.mdx index 97394fa9..d159fb55 100644 --- a/apps/docs/list-memories/examples/filtering.mdx +++ b/apps/docs/list-memories/examples/filtering.mdx @@ -13,12 +13,12 @@ Container tags use exact array matching - memories must have the exact same tags ```typescript // Single tag - matches memories with exactly ["user_123"] - const userMemories = await client.memories.list({ + const userMemories = await client.documents.list({ containerTags: ["user_123"] }); // Multiple tags - matches memories with exactly ["user_123", "project_ai"] - const projectMemories = await client.memories.list({ + const projectMemories = await client.documents.list({ containerTags: ["user_123", "project_ai"] }); ``` @@ -26,10 +26,10 @@ Container tags use exact array matching - memories must have the exact same tags ```python # Single tag - user_memories = client.memories.list(container_tags=["user_123"]) + user_memories = client.documents.list(container_tags=["user_123"]) # Multiple tags (exact match) - project_memories = client.memories.list( + project_memories = client.documents.list( container_tags=["user_123", "project_ai"] ) ``` @@ -72,7 +72,7 @@ The JSON structure forces explicit grouping to prevent unexpected results. **Filter Structure Rules:** - Always wrap conditions in `AND` or `OR` arrays (even single conditions) -- Use `JSON.stringify()` to convert the filter object to a string +- Pass the filter as an object (TypeScript/Python) or JSON string (cURL) - Each condition needs `key`, `value`, and `negate` properties - `negate: false` for normal matching, `negate: true` for exclusion @@ -83,26 +83,24 @@ The JSON structure forces explicit grouping to prevent unexpected results. ```typescript // Filter by single metadata field - const programmingMemories = await client.memories.list({ - filters: JSON.stringify({ + const programmingMemories = await client.documents.list({ + filters: { AND: [ { key: "category", value: "programming", negate: false } ] - }) + } }); ``` ```python - import json - # Filter by single metadata field - programming_memories = client.memories.list( - filters=json.dumps({ + programming_memories = client.documents.list( + filters={ "AND": [ {"key": "category", "value": "programming", "negate": False} ] - }) + } ) ``` @@ -124,28 +122,28 @@ The JSON structure forces explicit grouping to prevent unexpected results. ```typescript // All conditions must match - const reactTutorials = await client.memories.list({ - filters: JSON.stringify({ + const reactTutorials = await client.documents.list({ + filters: { AND: [ { key: "category", value: "tutorial", negate: false }, { key: "framework", value: "react", negate: false }, { key: "difficulty", value: "beginner", negate: false } ] - }) + } }); ``` ```python # All conditions must match - react_tutorials = client.memories.list( - filters=json.dumps({ + react_tutorials = client.documents.list( + filters={ "AND": [ {"key": "category", "value": "tutorial", "negate": False}, {"key": "framework", "value": "react", "negate": False}, {"key": "difficulty", "value": "beginner", "negate": False} ] - }) + } ) ``` @@ -167,28 +165,28 @@ The JSON structure forces explicit grouping to prevent unexpected results. ```typescript // Any condition can match - const frontendMemories = await client.memories.list({ - filters: JSON.stringify({ + const frontendMemories = await client.documents.list({ + filters: { OR: [ { key: "framework", value: "react", negate: false }, { key: "framework", value: "vue", negate: false }, { key: "framework", value: "angular", negate: false } ] - }) + } }); ``` ```python # Any condition can match - frontend_memories = client.memories.list( - filters=json.dumps({ + frontend_memories = client.documents.list( + filters={ "OR": [ {"key": "framework", "value": "react", "negate": False}, {"key": "framework", "value": "vue", "negate": False}, {"key": "framework", "value": "angular", "negate": False} ] - }) + } ) ``` @@ -210,8 +208,8 @@ The JSON structure forces explicit grouping to prevent unexpected results. ```typescript // Complex logic: programming AND (react OR advanced difficulty) - const advancedContent = await client.memories.list({ - filters: JSON.stringify({ + const advancedContent = await client.documents.list({ + filters: { AND: [ { key: "category", value: "programming", negate: false }, { @@ -221,15 +219,15 @@ The JSON structure forces explicit grouping to prevent unexpected results. ] } ] - }) + } }); ``` ```python # Complex logic: programming AND (react OR advanced difficulty) - advanced_content = client.memories.list( - filters=json.dumps({ + advanced_content = client.documents.list( + filters={ "AND": [ {"key": "category", "value": "programming", "negate": False}, { @@ -239,7 +237,7 @@ The JSON structure forces explicit grouping to prevent unexpected results. ] } ] - }) + } ) ``` @@ -265,8 +263,8 @@ Filter memories that contain specific values in array fields like participants, ```typescript // Find memories where john.doe participated - const meetingMemories = await client.memories.list({ - filters: JSON.stringify({ + const meetingMemories = await client.documents.list({ + filters: { AND: [ { key: "participants", @@ -275,15 +273,15 @@ Filter memories that contain specific values in array fields like participants, negate: false } ] - }) + } }); ``` ```python # Find memories where john.doe participated - meeting_memories = client.memories.list( - filters=json.dumps({ + meeting_memories = client.documents.list( + filters={ "AND": [ { "key": "participants", @@ -292,7 +290,7 @@ Filter memories that contain specific values in array fields like participants, "negate": False } ] - }) + } ) ``` @@ -314,8 +312,8 @@ Filter memories that contain specific values in array fields like participants, ```typescript // Find memories that don't include a specific team member - const filteredMemories = await client.memories.list({ - filters: JSON.stringify({ + const filteredMemories = await client.documents.list({ + filters: { AND: [ { key: "reviewers", @@ -330,15 +328,15 @@ Filter memories that contain specific values in array fields like participants, negate: false } ] - }) + } }); ``` ```python # Find memories that don't include a specific team member - filtered_memories = client.memories.list( - filters=json.dumps({ + filtered_memories = client.documents.list( + filters={ "AND": [ { "key": "reviewers", @@ -353,7 +351,7 @@ Filter memories that contain specific values in array fields like participants, "negate": False } ] - }) + } ) ``` @@ -375,8 +373,8 @@ Filter memories that contain specific values in array fields like participants, ```typescript // Find memories involving any of several team leads - const leadershipMemories = await client.memories.list({ - filters: JSON.stringify({ + const leadershipMemories = await client.documents.list({ + filters: { OR: [ { key: "attendees", @@ -394,7 +392,7 @@ Filter memories that contain specific values in array fields like participants, filterType: "array_contains" } ] - }), + }, sort: "updatedAt", order: "desc" }); @@ -403,8 +401,8 @@ Filter memories that contain specific values in array fields like participants, ```python # Find memories involving any of several team leads - leadership_memories = client.memories.list( - filters=json.dumps({ + leadership_memories = client.documents.list( + filters={ "OR": [ { "key": "attendees", @@ -422,7 +420,7 @@ Filter memories that contain specific values in array fields like participants, "filterType": "array_contains" } ] - }), + }, sort="updatedAt", order="desc" ) @@ -447,14 +445,14 @@ Filter memories that contain specific values in array fields like participants, ```typescript - const filteredMemories = await client.memories.list({ + const filteredMemories = await client.documents.list({ containerTags: ["user_123"], - filters: JSON.stringify({ + filters: { AND: [ { key: "category", value: "tutorial", negate: false }, { key: "framework", value: "react", negate: false } ] - }), + }, sort: "updatedAt", order: "desc", limit: 50 @@ -463,14 +461,14 @@ Filter memories that contain specific values in array fields like participants, ```python - filtered_memories = client.memories.list( + filtered_memories = client.documents.list( container_tags=["user_123"], - filters=json.dumps({ + filters={ "AND": [ {"key": "category", "value": "tutorial", "negate": False}, {"key": "framework", "value": "react", "negate": False} ] - }), + }, sort="updatedAt", order="desc", limit=50 @@ -495,9 +493,9 @@ Filter memories that contain specific values in array fields like participants, **Common Mistakes:** -- Using bare condition objects: `{"key": "category", "value": "programming"}` -- Forgetting JSON.stringify: passing objects instead of strings +- Using bare condition objects: `{"key": "category", "value": "programming"}` without wrapping in `AND` or `OR` - Missing negate property: always include `"negate": false` or `"negate": true` +- For cURL requests: forgetting to properly escape the JSON string diff --git a/apps/docs/list-memories/examples/monitoring.mdx b/apps/docs/list-memories/examples/monitoring.mdx index 248d945e..7c373d3c 100644 --- a/apps/docs/list-memories/examples/monitoring.mdx +++ b/apps/docs/list-memories/examples/monitoring.mdx @@ -10,7 +10,7 @@ Monitor memory processing status and track completion rates using the list endpo ```typescript - const response = await client.memories.list({ limit: 100 }); + const response = await client.documents.list({ limit: 100 }); const statusCounts = response.memories.reduce((acc: any, memory) => { acc[memory.status] = (acc[memory.status] || 0) + 1; @@ -22,7 +22,7 @@ Monitor memory processing status and track completion rates using the list endpo ```python - response = client.memories.list(limit=100) + response = client.documents.list(limit=100) status_counts = {} for memory in response.memories: @@ -48,7 +48,7 @@ Monitor memory processing status and track completion rates using the list endpo ```typescript - const response = await client.memories.list({ limit: 100 }); + const response = await client.documents.list({ limit: 100 }); const processing = response.memories.filter(m => ['queued', 'extracting', 'chunking', 'embedding', 'indexing'].includes(m.status) @@ -59,7 +59,7 @@ Monitor memory processing status and track completion rates using the list endpo ```python - response = client.memories.list(limit=100) + response = client.documents.list(limit=100) processing_statuses = ['queued', 'extracting', 'chunking', 'embedding', 'indexing'] processing = [m for m in response.memories if m.status in processing_statuses] @@ -83,21 +83,22 @@ Monitor memory processing status and track completion rates using the list endpo ```typescript - const failedMemories = await client.memories.list({ - filters: "status:failed", - limit: 50 - }); + const response = await client.documents.list({ limit: 100 }); - failedMemories.memories.forEach(memory => { + const failedMemories = response.memories.filter(m => m.status === 'failed'); + + failedMemories.forEach(memory => { console.log(`Failed: ${memory.id} - ${memory.title || 'Untitled'}`); }); ``` ```python - failed_memories = client.memories.list(filters="status:failed", limit=50) + response = client.documents.list(limit=100) - for memory in failed_memories.memories: + failed_memories = [m for m in response.memories if m.status == 'failed'] + + for memory in failed_memories: title = memory.title or 'Untitled' print(f"Failed: {memory.id} - {title}") ``` @@ -107,8 +108,8 @@ Monitor memory processing status and track completion rates using the list endpo curl -X POST "https://api.supermemory.ai/v3/documents/list" \ -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \ -H "Content-Type: application/json" \ - -d '{"filters": "status:failed", "limit": 50}' | \ - jq '.memories[] | {id, title, status}' + -d '{"limit": 100}' | \ + jq '.memories[] | select(.status == "failed") | {id, title, status}' ``` diff --git a/apps/docs/list-memories/examples/pagination.mdx b/apps/docs/list-memories/examples/pagination.mdx index 56004b89..9a975acc 100644 --- a/apps/docs/list-memories/examples/pagination.mdx +++ b/apps/docs/list-memories/examples/pagination.mdx @@ -11,13 +11,13 @@ Handle large memory collections efficiently using pagination to process data in ```typescript // Get first page - const page1 = await client.memories.list({ + const page1 = await client.documents.list({ limit: 20, page: 1 }); // Get next page - const page2 = await client.memories.list({ + const page2 = await client.documents.list({ limit: 20, page: 2 }); @@ -29,10 +29,10 @@ Handle large memory collections efficiently using pagination to process data in ```python # Get first page - page1 = client.memories.list(limit=20, page=1) + page1 = client.documents.list(limit=20, page=1) # Get next page - page2 = client.memories.list(limit=20, page=2) + page2 = client.documents.list(limit=20, page=2) print(f"Page 1: {len(page1.memories)} memories") print(f"Page 2: {len(page2.memories)} memories") @@ -64,7 +64,7 @@ Handle large memory collections efficiently using pagination to process data in let hasMore = true; while (hasMore) { - const response = await client.memories.list({ + const response = await client.documents.list({ page: currentPage, limit: 50 }); @@ -82,7 +82,7 @@ Handle large memory collections efficiently using pagination to process data in has_more = True while has_more: - response = client.memories.list(page=current_page, limit=50) + response = client.documents.list(page=current_page, limit=50) print(f"Page {current_page}: {len(response.memories)} memories") diff --git a/apps/docs/list-memories/overview.mdx b/apps/docs/list-memories/overview.mdx index d1631030..13976fe7 100644 --- a/apps/docs/list-memories/overview.mdx +++ b/apps/docs/list-memories/overview.mdx @@ -18,7 +18,7 @@ Retrieve paginated memories with filtering and sorting options from your Superme apiKey: process.env.SUPERMEMORY_API_KEY! }); - const memories = await client.memories.list({ limit: 10 }); + const memories = await client.documents.list({ limit: 10 }); console.log(memories); ``` @@ -28,7 +28,7 @@ Retrieve paginated memories with filtering and sorting options from your Superme import os client = Supermemory(api_key=os.environ.get("SUPERMEMORY_API_KEY")) - memories = client.memories.list(limit=10) + memories = client.documents.list(limit=10) print(f"Found {len(memories.memories)} memories") ``` diff --git a/apps/docs/memory-api/features/filtering.mdx b/apps/docs/memory-api/features/filtering.mdx index 3873e606..e7e3a14d 100644 --- a/apps/docs/memory-api/features/filtering.mdx +++ b/apps/docs/memory-api/features/filtering.mdx @@ -168,7 +168,7 @@ curl --location 'https://api.supermemory.ai/v3/documents' \ ``` ```typescript Typescript -await client.memories.create({ +await client.documents.create({ content: "quarterly planning meeting discussion", metadata: { participants: ["john.doe", "sarah.smith", "mike.wilson"] @@ -177,7 +177,7 @@ await client.memories.create({ ``` ```python Python -client.memories.create( +client.documents.create( content="quarterly planning meeting discussion", metadata={ "participants": ["john.doe", "sarah.smith", "mike.wilson"] diff --git a/apps/docs/memory-api/ingesting.mdx b/apps/docs/memory-api/ingesting.mdx index c2839252..301fb66a 100644 --- a/apps/docs/memory-api/ingesting.mdx +++ b/apps/docs/memory-api/ingesting.mdx @@ -205,7 +205,7 @@ const client = new Supermemory({ }) // Method 1: Using SDK uploadFile method (RECOMMENDED) -const result = await client.memories.uploadFile({ +const result = await client.documents.uploadFile({ file: fs.createReadStream('/path/to/document.pdf'), containerTags: 'research_project' // String, not array! }) @@ -234,7 +234,7 @@ from supermemory import Supermemory client = Supermemory(api_key="your_api_key") # Method 1: Using SDK upload_file method (RECOMMENDED) -result = client.memories.upload_file( +result = client.documents.upload_file( file=open('document.pdf', 'rb'), container_tags='research_project' # String parameter name ) diff --git a/apps/docs/memory-api/sdks/python.mdx b/apps/docs/memory-api/sdks/python.mdx index 33700552..0888f2b0 100644 --- a/apps/docs/memory-api/sdks/python.mdx +++ b/apps/docs/memory-api/sdks/python.mdx @@ -78,7 +78,7 @@ from supermemory import Supermemory client = Supermemory() -client.memories.upload_file( +client.documents.upload_file( file=Path("/path/to/file"), ) ``` @@ -146,7 +146,7 @@ client = Supermemory( ) # Or, configure per-request: -client.with_options(max_retries=5).memories.add( +client.with_options(max_retries=5).documents.add( content="This is a detailed article about machine learning concepts...", ) ``` @@ -171,7 +171,7 @@ client = Supermemory( ) # Override per-request: -client.with_options(timeout=5.0).memories.add( +client.with_options(timeout=5.0).documents.add( content="This is a detailed article about machine learning concepts...", ) ``` @@ -214,12 +214,12 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to from supermemory import Supermemory client = Supermemory() -response = client.memories.with_raw_response.add( +response = client.documents.with_raw_response.add( content="This is a detailed article about machine learning concepts...", ) print(response.headers.get('X-My-Header')) -memory = response.parse() # get the object that `memories.add()` would have returned +memory = response.parse() # get the object that `documents.add()` would have returned print(memory.id) ``` @@ -234,7 +234,7 @@ The above interface eagerly reads the full response body when you make the reque To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods. ```python -with client.memories.with_streaming_response.add( +with client.documents.with_streaming_response.add( content="This is a detailed article about machine learning concepts...", ) as response: print(response.headers.get("X-My-Header")) diff --git a/apps/docs/memory-api/sdks/typescript.mdx b/apps/docs/memory-api/sdks/typescript.mdx index bea67033..d6670b10 100644 --- a/apps/docs/memory-api/sdks/typescript.mdx +++ b/apps/docs/memory-api/sdks/typescript.mdx @@ -41,10 +41,10 @@ const client = new Supermemory({ }); async function main() { - const params: supermemory.MemoryAddParams = { + const params: Supermemory.AddParams = { content: 'This is a detailed article about machine learning concepts...', }; - const response: supermemory.MemoryAddResponse = await client.add(params); + const response: Supermemory.AddResponse = await client.add(params); } main(); @@ -68,17 +68,17 @@ import Supermemory, { toFile } from 'supermemory'; const client = new Supermemory(); // If you have access to Node `fs` we recommend using `fs.createReadStream()`: -await client.memories.uploadFile({ file: fs.createReadStream('/path/to/file') }); +await client.documents.uploadFile({ file: fs.createReadStream('/path/to/file') }); // Or if you have the web `File` API you can pass a `File` instance: -await client.memories.uploadFile({ file: new File(['my bytes'], 'file') }); +await client.documents.uploadFile({ file: new File(['my bytes'], 'file') }); // You can also pass a `fetch` `Response`: -await client.memories.uploadFile({ file: await fetch('https://somesite/file') }); +await client.documents.uploadFile({ file: await fetch('https://somesite/file') }); // Finally, if none of the above are convenient, you can use our `toFile` helper: -await client.memories.uploadFile({ file: await toFile(Buffer.from('my bytes'), 'file') }); -await client.memories.uploadFile({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') }); +await client.documents.uploadFile({ file: await toFile(Buffer.from('my bytes'), 'file') }); +await client.documents.uploadFile({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') }); ``` ## Handling errors @@ -90,7 +90,7 @@ a subclass of `APIError` will be thrown: ```ts async function main() { - const response = await client.memories + const response = await client.documents .add({ content: 'This is a detailed article about machine learning concepts...' }) .catch(async (err) => { if (err instanceof supermemory.APIError) { @@ -175,13 +175,13 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse ```ts const client = new Supermemory(); -const response = await client.memories +const response = await client.documents .add({ content: 'This is a detailed article about machine learning concepts...' }) .asResponse(); console.debug(response.headers.get('X-My-Header')); console.debug(response.statusText); // access the underlying Response object -const { data: response, response: raw } = await client.memories +const { data: response, response: raw } = await client.documents .add({ content: 'This is a detailed article about machine learning concepts...' }) .withResponse(); console.debug(raw.headers.get('X-My-Header')); diff --git a/apps/docs/memory-api/track-progress.mdx b/apps/docs/memory-api/track-progress.mdx index 164ce044..65c0462f 100644 --- a/apps/docs/memory-api/track-progress.mdx +++ b/apps/docs/memory-api/track-progress.mdx @@ -105,20 +105,20 @@ Track specific document processing status. ```typescript Typescript -const memory = await client.memories.get("doc_abc123"); +const memory = await client.documents.get("doc_abc123"); console.log(`Status: ${memory.status}`); // Poll for completion while (memory.status !== 'done') { await new Promise(r => setTimeout(r, 2000)); - memory = await client.memories.get("doc_abc123"); + memory = await client.documents.get("doc_abc123"); console.log(`Status: ${memory.status}`); } ``` ```python Python -memory = client.memories.get("doc_abc123") +memory = client.documents.get("doc_abc123") print(f"Status: {memory['status']}") @@ -126,7 +126,7 @@ print(f"Status: {memory['status']}") import time while memory['status'] != 'done': time.sleep(2) - memory = client.memories.get("doc_abc123") + memory = client.documents.get("doc_abc123") print(f"Status: {memory['status']}") ``` @@ -178,7 +178,7 @@ async function waitForProcessing(documentId: string, maxWaitMs = 300000) { const pollInterval = 2000; // 2 seconds while (Date.now() - startTime < maxWaitMs) { - const doc = await client.memories.get(documentId); + const doc = await client.documents.get(documentId); if (doc.status === 'done') { return doc; @@ -205,7 +205,7 @@ async function trackBatch(documentIds: string[]) { // Initial check for (const id of documentIds) { - const doc = await client.memories.get(id); + const doc = await client.documents.get(id); statuses.set(id, doc.status); } @@ -215,7 +215,7 @@ async function trackBatch(documentIds: string[]) { for (const id of documentIds) { if (statuses.get(id) !== 'done' && statuses.get(id) !== 'failed') { - const doc = await client.memories.get(id); + const doc = await client.documents.get(id); statuses.set(id, doc.status); } } diff --git a/apps/docs/migration/from-mem0.mdx b/apps/docs/migration/from-mem0.mdx index c4ec85ff..6903379e 100644 --- a/apps/docs/migration/from-mem0.mdx +++ b/apps/docs/migration/from-mem0.mdx @@ -200,7 +200,7 @@ results = client.search( ``` ```python Supermemory -results = client.memories.search( +results = client.documents.search( query="user preferences", container_tags=["user_alice"] ) @@ -219,7 +219,7 @@ memories = client.get_all( ``` ```python Supermemory -memories = client.memories.list( +memories = client.documents.list( container_tags=["user_alice"], limit=100 ) @@ -236,7 +236,7 @@ client.delete(memory_id="mem_123") ``` ```python Supermemory -client.memories.delete("mem_123") +client.documents.delete("mem_123") ``` diff --git a/apps/docs/migration/from-zep.mdx b/apps/docs/migration/from-zep.mdx index 1da0980b..f6585605 100644 --- a/apps/docs/migration/from-zep.mdx +++ b/apps/docs/migration/from-zep.mdx @@ -111,7 +111,7 @@ memories = client.memory.get(session_id="user_123") ``` ```python Supermemory -documents = client.memories.list({ +documents = client.documents.list({ "containerTag": ["user_123"], "limit": 100 }) diff --git a/apps/docs/migration/mem0-migration-script.py b/apps/docs/migration/mem0-migration-script.py index c83c208d..ff33f10a 100644 --- a/apps/docs/migration/mem0-migration-script.py +++ b/apps/docs/migration/mem0-migration-script.py @@ -235,7 +235,7 @@ def verify_migration(api_key: str, expected_count: int): try: # Check imported memories - result = client.memories.list(container_tags=["imported_from_mem0"], limit=100) + result = client.documents.list(container_tags=["imported_from_mem0"], limit=100) total_imported = result["pagination"]["totalItems"] print(f"✅ Found {total_imported} imported memories in Supermemory") diff --git a/apps/docs/quickstart.mdx b/apps/docs/quickstart.mdx index 11c650ed..3887f2c8 100644 --- a/apps/docs/quickstart.mdx +++ b/apps/docs/quickstart.mdx @@ -50,14 +50,18 @@ conversation = [ # Get user profile + relevant memories for context profile = client.profile(container_tag=USER_ID, q=conversation[-1]["content"]) +static = "\n".join(profile.profile.static) +dynamic = "\n".join(profile.profile.dynamic) +memories = "\n".join(r.content for r in profile.search_results.results) + context = f"""Static profile: -{"\n".join(profile.profile.static)} +{static} Dynamic profile: -{"\n".join(profile.profile.dynamic)} +{dynamic} Relevant memories: -{"\n".join(r.content for r in profile.search_results.results)}""" +{memories}""" # Build messages with memory-enriched context messages = [{"role": "system", "content": f"User context:\n{context}"}, *conversation] diff --git a/apps/docs/search.mdx b/apps/docs/search.mdx index 17df0ff2..15f4861d 100644 --- a/apps/docs/search.mdx +++ b/apps/docs/search.mdx @@ -20,7 +20,7 @@ Search through your memories and documents with a single API call. const client = new Supermemory(); - const results = await client.search({ + const results = await client.search.memories({ q: "machine learning", containerTag: "user_123", searchMode: "hybrid", @@ -28,7 +28,7 @@ Search through your memories and documents with a single API call. }); results.results.forEach(result => { - console.log(result.content, result.similarity); + console.log(result.memory || result.chunk, result.similarity); }); ``` @@ -38,7 +38,7 @@ Search through your memories and documents with a single API call. client = Supermemory() - results = client.search( + results = client.search.memories( q="machine learning", container_tag="user_123", search_mode="hybrid", @@ -46,7 +46,7 @@ Search through your memories and documents with a single API call. ) for result in results.results: - print(result.content, result.similarity) + print(result.memory or result.chunk, result.similarity) ``` @@ -70,15 +70,19 @@ Search through your memories and documents with a single API call. "results": [ { "id": "mem_xyz", - "content": "User is interested in machine learning for product recommendations", + "memory": "User is interested in machine learning for product recommendations", "similarity": 0.91, - "metadata": { "topic": "interests" } + "metadata": { "topic": "interests" }, + "updatedAt": "2024-01-15T10:30:00.000Z", + "version": 1 }, { "id": "chunk_abc", - "content": "Machine learning enables personalized experiences at scale...", + "chunk": "Machine learning enables personalized experiences at scale...", "similarity": 0.87, - "metadata": { "source": "onboarding_doc" } + "metadata": { "source": "onboarding_doc" }, + "updatedAt": "2024-01-14T09:15:00.000Z", + "version": 1 } ], "timing": 92, @@ -86,6 +90,10 @@ Search through your memories and documents with a single API call. } ``` + +In hybrid mode, results contain either a `memory` field (extracted facts) or a `chunk` field (document content), depending on the source. + + --- ## Parameters @@ -107,14 +115,14 @@ Search through your memories and documents with a single API call. ```typescript // Hybrid: memories + document chunks (recommended) -await client.search({ +await client.search.memories({ q: "quarterly goals", containerTag: "user_123", searchMode: "hybrid" }); // Memories only: just extracted facts -await client.search({ +await client.search.memories({ q: "user preferences", containerTag: "user_123", searchMode: "memories" @@ -128,7 +136,7 @@ await client.search({ Filter by `containerTag` to scope results to a user or project: ```typescript -const results = await client.search({ +const results = await client.search.memories({ q: "project updates", containerTag: "user_123", searchMode: "hybrid" @@ -138,7 +146,7 @@ const results = await client.search({ Use `filters` for metadata-based filtering: ```typescript -const results = await client.search({ +const results = await client.search.memories({ q: "meeting notes", containerTag: "user_123", filters: { @@ -169,7 +177,7 @@ const results = await client.search({ Re-scores results for better relevance. Adds ~100ms latency. ```typescript -const results = await client.search({ +const results = await client.search.memories({ q: "complex technical question", containerTag: "user_123", rerank: true @@ -182,10 +190,10 @@ Control result quality vs quantity: ```typescript // Broad search — more results -await client.search({ q: "...", threshold: 0.3 }); +await client.search.memories({ q: "...", threshold: 0.3 }); // Precise search — fewer, better results -await client.search({ q: "...", threshold: 0.8 }); +await client.search.memories({ q: "...", threshold: 0.8 }); ``` --- @@ -196,7 +204,7 @@ Optimal configuration for conversational AI: ```typescript async function getContext(userId: string, message: string) { - const results = await client.search({ + const results = await client.search.memories({ q: message, containerTag: userId, searchMode: "hybrid", @@ -205,7 +213,7 @@ async function getContext(userId: string, message: string) { }); return results.results - .map(r => r.content) + .map(r => r.memory || r.chunk) .join('\n\n'); } ``` @@ -214,10 +222,12 @@ async function getContext(userId: string, message: string) { ```typescript interface SearchResult { id: string; - content: string; // Memory or chunk content + memory?: string; // Present for memory results + chunk?: string; // Present for document chunk results similarity: number; // 0-1 metadata: object | null; updatedAt: string; + version: number; } interface SearchResponse { diff --git a/apps/docs/search/overview.mdx b/apps/docs/search/overview.mdx index 3f888b02..32c2d7da 100644 --- a/apps/docs/search/overview.mdx +++ b/apps/docs/search/overview.mdx @@ -345,7 +345,7 @@ This is useful when: ```typescript TypeScript // Get a specific document by ID -const document = await client.memories.get("doc_abc123"); +const document = await client.documents.get("doc_abc123"); console.log(document.content); // Full document content console.log(document.status); // Processing status @@ -355,7 +355,7 @@ console.log(document.summary); // AI-generated summary ```python Python # Get a specific document by ID -document = client.memories.get("doc_abc123") +document = client.documents.get("doc_abc123") print(document.content) # Full document content print(document.status) # Processing status diff --git a/apps/docs/test.py b/apps/docs/test.py index ee5309d6..2e270dad 100644 --- a/apps/docs/test.py +++ b/apps/docs/test.py @@ -12,14 +12,18 @@ conversation = [ # Get user profile + relevant memories for context profile = client.profile(container_tag=USER_ID, q=conversation[-1]["content"]) +static = "\n".join(profile.profile.static) +dynamic = "\n".join(profile.profile.dynamic) +memories = "\n".join(r.content for r in profile.search_results.results) + context = f"""Static profile: -{ "\n".join(profile.profile.static)} +{static} Dynamic profile: -{"\n".join(profile.profile.dynamic)} +{dynamic} Relevant memories: -{"\n".join(r.content for r in profile.search_results.results)}""" +{memories}""" # Build messages with memory-enriched context messages = [{"role": "system", "content": f"User context:\n{context}"}, *conversation] diff --git a/apps/docs/update-delete-memories/overview.mdx b/apps/docs/update-delete-memories/overview.mdx index f7e53973..a4f5f0e1 100644 --- a/apps/docs/update-delete-memories/overview.mdx +++ b/apps/docs/update-delete-memories/overview.mdx @@ -20,7 +20,7 @@ const client = new Supermemory({ }); // Update by memory ID -const updated = await client.memories.update('memory_id_123', { +const updated = await client.documents.update('memory_id_123', { content: 'Updated content here', metadata: { version: 2, updated: true } }); @@ -36,7 +36,7 @@ import os client = Supermemory(api_key=os.environ.get("SUPERMEMORY_API_KEY")) # Update by memory ID -updated = client.memories.update( +updated = client.documents.update( 'memory_id_123', content='Updated content here', metadata={'version': 2, 'updated': True} @@ -165,18 +165,18 @@ Delete individual memories by their ID. This is a permanent hard delete with no ```typescript Typescript // Hard delete - permanently removes memory -await client.memories.delete('memory_id_123'); +await client.documents.delete('memory_id_123'); console.log('Memory deleted successfully'); ``` ```python Python # Hard delete - permanently removes memory -client.memories.delete('memory_id_123') +client.documents.delete('memory_id_123') print('Memory deleted successfully') # Error handling for single delete try: - client.memories.delete('memory_id_123') + client.documents.delete('memory_id_123') print('Delete successful') except NotFoundError: print('Memory not found or already deleted') @@ -204,7 +204,7 @@ Delete multiple memories at once by providing an array of memory IDs. Maximum of ```typescript Typescript // Bulk delete by memory IDs -const result = await client.memories.bulkDelete({ +const result = await client.documents.deleteBulk({ ids: [ 'memory_id_1', 'memory_id_2', @@ -225,7 +225,7 @@ console.log('Bulk delete result:', result); ```python Python # Bulk delete by memory IDs -result = client.memories.bulk_delete( +result = client.documents.delete_bulk( ids=[ 'memory_id_1', 'memory_id_2', @@ -276,7 +276,7 @@ Delete all memories within specific container tags. This is useful for cleaning ```typescript Typescript // Delete all memories in specific container tags -const result = await client.memories.bulkDelete({ +const result = await client.documents.deleteBulk({ containerTags: ['user-123', 'project-old', 'archived-content'] }); @@ -290,7 +290,7 @@ console.log('Bulk delete by tags result:', result); ```python Python # Delete all memories in specific container tags -result = client.memories.bulk_delete( +result = client.documents.delete_bulk( container_tags=['user-123', 'project-old', 'archived-content'] ) @@ -329,7 +329,7 @@ For applications requiring audit trails or recovery mechanisms, implement soft d ```typescript Typescript // Soft delete pattern using metadata -await client.memories.update('memory_id', { +await client.documents.update('memory_id', { metadata: { deleted: true, deletedAt: new Date().toISOString(), @@ -338,40 +338,40 @@ await client.memories.update('memory_id', { }); // Filter out deleted memories in searches -const activeMemories = await client.memories.list({ - filters: JSON.stringify({ +const activeMemories = await client.documents.list({ + filters: { AND: [ { key: "deleted", value: "true", negate: true } ] - }) + } }); -console.log('Active memories:', activeMemories.results.length); +console.log('Active memories:', activeMemories.memories.length); ``` ```python Python from datetime import datetime -import json # Soft delete pattern using metadata -client.memories.update('memory_id', { - 'metadata': { +client.documents.update( + 'memory_id', + metadata={ 'deleted': True, 'deletedAt': datetime.now().isoformat(), 'deletedBy': 'user_123' } -}) +) # Filter out deleted memories -active_memories = client.memories.list( - filters=json.dumps({ +active_memories = client.documents.list( + filters={ "AND": [ {"key": "deleted", "value": "true", "negate": True} ] - }) + } ) -print(f'Active memories: {len(active_memories.results)}') +print(f'Active memories: {len(active_memories.memories)}') ``` ```bash cURL @@ -407,7 +407,7 @@ async function batchDeleteMemories(memoryIds: string[], batchSize = 100) { console.log(`Processing batch ${Math.floor(i/batchSize) + 1} of ${Math.ceil(memoryIds.length/batchSize)}`); try { - const result = await client.memories.bulkDelete({ ids: batch }); + const result = await client.documents.deleteBulk({ ids: batch }); results.push(result); // Brief delay between batches to avoid rate limiting @@ -446,7 +446,7 @@ def batch_delete_memories(memory_ids, batch_size=100): print(f'Processing batch {batch_num} of {total_batches}') try: - result = client.memories.bulk_delete(ids=batch) + result = client.documents.delete_bulk(ids=batch) results.append(result) # Brief delay between batches to avoid rate limiting