From fd7794ce95623f9bb139e5dcd61c9e61345a7b1d Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 05:45:41 +0000 Subject: [PATCH] docs: update JavaScript SDK vector delete documentation for bulk delete support - Update vector.delete() method signature to support variadic arguments - Add comprehensive examples showing single and bulk delete patterns - Update vector storage examples to demonstrate bulk deletion - Enhance changelog entry for v0.0.131 with detailed description Reflects changes from commit 6548924bb7bd90b5c71e49c66b6b2a22dd9a885e in sdk-js Co-Authored-By: jhaynie@agentuity.com --- content/Changelog/sdk-js.mdx | 2 +- content/SDKs/javascript/api-reference.mdx | 24 ++++++++++++++++------ content/SDKs/javascript/examples/index.mdx | 11 ++++++---- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/content/Changelog/sdk-js.mdx b/content/Changelog/sdk-js.mdx index c73dd650..aeb9e9d6 100644 --- a/content/Changelog/sdk-js.mdx +++ b/content/Changelog/sdk-js.mdx @@ -15,7 +15,7 @@ This page documents the release history of the [Agentuity JavaScript SDK](https: ### Changes -- **Added**: Support for bulk delete in vector storage ([PR #145](https://github.com/agentuity/sdk-js/pull/145)) +- **Added**: Support for bulk delete in vector storage - The `vector.delete()` method now accepts multiple keys as variadic arguments, allowing efficient bulk deletion of vectors. Supports both single key deletion (`delete(name, key)`) and bulk deletion (`delete(name, key1, key2, key3)`) patterns. This is more efficient than making multiple individual delete calls. ([PR #145](https://github.com/agentuity/sdk-js/pull/145)) - **Changed**: Improved documentation of vector search parameters and tightened vector search metadata type definition ([PR #146](https://github.com/agentuity/sdk-js/pull/146)) ## v0.0.130 diff --git a/content/SDKs/javascript/api-reference.mdx b/content/SDKs/javascript/api-reference.mdx index ae4d6ea0..417fdb6f 100644 --- a/content/SDKs/javascript/api-reference.mdx +++ b/content/SDKs/javascript/api-reference.mdx @@ -259,25 +259,37 @@ for (const result of results) { } ``` -#### `delete(name: string, key: string): Promise` +#### `delete(name: string, ...keys: string[]): Promise` -Deletes a vector from the vector storage. +Deletes one or more vectors from the vector storage. ##### Parameters - `name`: The name of the vector storage -- `key`: The ID of the vector to delete +- `keys`: One or more keys of the vectors to delete ##### Return Value -Returns a Promise that resolves to the number of vectors that were deleted (0 or 1). +Returns a Promise that resolves to the number of vectors that were deleted. -##### Example +##### Examples ```typescript // Delete a single vector const deletedCount = await context.vector.delete('product-descriptions', 'id1'); -console.log(`Deleted ${deletedCount} vector(s)`); +console.log(`Deleted ${deletedCount} vector(s)`); // Output: Deleted 1 vector(s) + +// Delete multiple vectors in bulk (more efficient than individual calls) +const deletedCount = await context.vector.delete('product-descriptions', 'id1', 'id2', 'id3'); +console.log(`Deleted ${deletedCount} vector(s)`); // Output: Deleted 3 vector(s) + +// Delete with array spread +const keysToDelete = ['id1', 'id2', 'id3']; +const deletedCount = await context.vector.delete('product-descriptions', ...keysToDelete); + +// Handle cases where some vectors might not exist +const deletedCount = await context.vector.delete('product-descriptions', 'existing-id', 'non-existent-id'); +console.log(`Deleted ${deletedCount} vector(s)`); // Output: Deleted 1 vector(s) ``` ### Object Storage diff --git a/content/SDKs/javascript/examples/index.mdx b/content/SDKs/javascript/examples/index.mdx index ed2ff884..d115035c 100644 --- a/content/SDKs/javascript/examples/index.mdx +++ b/content/SDKs/javascript/examples/index.mdx @@ -155,15 +155,18 @@ const handler: AgentHandler = async (request, response, context) => { } case 'delete': { - // Delete a product from vector storage + // Delete products from vector storage if (!products || !Array.isArray(products) || products.length === 0) { - return response.json({ error: 'No product ID to delete' }); + return response.json({ error: 'No product IDs to delete' }); } - const count = await context.vector.delete('products', products[0]); + // Support both single and bulk deletion + const productIds = products.map(p => p.id || p); + const count = await context.vector.delete('products', ...productIds); return response.json({ - message: `Deleted ${count} product successfully` + message: `Deleted ${count} product(s) successfully`, + deletedCount: count }); }