Documentation Index
Fetch the complete documentation index at: https://docs.cyborg.co/llms.txt
Use this file to discover all available pages before exploring further.
Adds new vectors to the index or updates existing ones. Supports both dictionary format and separate arrays for IDs and vectors.
# Option 1: Dictionary format
index.upsert(items)
# Option 2: Separate arrays
index.upsert(ids, vectors)
Parameters
| Parameter | Type | Default | Description |
items | List[Dict] | - | List of dictionaries containing vector data |
Where each dictionary can contain:
[
{
"id": str, # Unique identifier for the vector
"vector": List[float], # The vector data
"contents": str | bytes, # Optional content (accepts both strings and bytes, encoded to bytes and encrypted before storage)
"metadata": Dict # Optional key-value pairs for filtering and retrieval
},
...
]
The contents field accepts both strings and bytes. All contents are encoded to bytes and encrypted before storage, and will be returned as bytes when retrieved with get().
Option 2: Separate Arrays
| Parameter | Type | Default | Description |
ids | List[str] | - | List of unique vector identifiers |
vectors | List[List[float]] or np.ndarray | - | Vector data as 2D array |
Returns
None
Example Usage
# Basic vector upsert
items = [
{
'id': 'doc1',
'vector': [0.1, 0.2, 0.3, 0.4]
},
{
'id': 'doc2',
'vector': [0.5, 0.6, 0.7, 0.8]
}
]
index.upsert(items)
Separate Arrays
import numpy as np
# Using separate arrays
ids = ['vec1', 'vec2', 'vec3']
vectors = np.random.rand(3, 128).astype(np.float32)
index.upsert(ids, vectors)