Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions content/SDKs/javascript/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,25 @@ for (const result of results) {
}
```

#### `delete(name: string, ...ids: string[]): Promise<number>`
#### `delete(name: string, key: string): Promise<number>`

Deletes vectors from the vector storage.
Deletes a vector from the vector storage.

##### Parameters

- `name`: The name of the vector storage
- `ids`: One or more IDs of vectors to delete
- `key`: The ID of the vector to delete

##### Return Value

Returns a Promise that resolves to the number of vectors that were deleted.
Returns a Promise that resolves to the number of vectors that were deleted (0 or 1).

##### Example

```typescript
// Delete vectors
const deletedCount = await context.vector.delete('product-descriptions', 'id1', 'id2', 'id3');
console.log(`Deleted ${deletedCount} vectors`);
// Delete a single vector
const deletedCount = await context.vector.delete('product-descriptions', 'id1');
console.log(`Deleted ${deletedCount} vector(s)`);
```

## Agent Communication
Expand Down
10 changes: 5 additions & 5 deletions content/SDKs/javascript/examples/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ const handler: AgentHandler = async (request, response, context) => {
}

case 'delete': {
// Delete products from vector storage
if (!Array.isArray(products) || products.length === 0) {
return response.json({ error: 'No product IDs to delete' });
// Delete a product from vector storage
if (!products || !Array.isArray(products) || products.length === 0) {
return response.json({ error: 'No product ID to delete' });
}

const count = await context.vector.delete('products', ...products);
const count = await context.vector.delete('products', products[0]);

return response.json({
message: `Deleted ${count} products successfully`
message: `Deleted ${count} product successfully`
});
}

Expand Down
16 changes: 8 additions & 8 deletions content/SDKs/python/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -458,30 +458,30 @@ except Exception as e:
# Handle the error appropriately
```

#### `async delete(name: str, *ids: str) -> int`
#### `async delete(name: str, key: str) -> int`

Deletes vectors from the vector storage.
Deletes a vector from the vector storage.

##### Parameters

- `name`: The name of the vector storage
- `ids`: One or more IDs of vectors to delete
- `key`: The ID of the vector to delete

##### Return Value

Returns the number of vectors that were deleted.
Returns the number of vectors that were deleted (0 or 1).

##### Example

```python
from agentuity.sdk import AgentContext

# Delete vectors with error handling
# Delete a single vector with error handling
try:
deleted_count = await context.vector.delete("product-descriptions", "id1", "id2", "id3")
context.logger.info(f"Deleted {deleted_count} vectors")
deleted_count = await context.vector.delete("product-descriptions", "id1")
context.logger.info(f"Deleted {deleted_count} vector(s)")
except Exception as e:
context.logger.error(f"Failed to delete vectors: {str(e)}")
context.logger.error(f"Failed to delete vector: {str(e)}")
# Handle the error appropriately
```

Expand Down
14 changes: 7 additions & 7 deletions content/SDKs/python/examples/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,19 @@ async def run(request: AgentRequest, response: AgentResponse, context: AgentCont
})

elif action == "delete":
# Delete products from vector storage
# Delete a product from vector storage
if not isinstance(products, list) or len(products) == 0:
return response.json({"error": "No product IDs to delete"})
return response.json({"error": "No product ID to delete"})

# Extract product IDs
product_ids = [p["id"] for p in products]
# Extract first product ID (single key deletion)
product_id = products[0]["id"]

# Delete from vector database
count = await context.vector.delete("products", product_ids[0])
count = await context.vector.delete("products", product_id)

return response.json({
"message": f"Deleted {count} products successfully",
"ids": product_ids
"message": f"Deleted {count} product successfully",
"id": product_id
})

else:
Expand Down