It’s also possible to store item contents alongside vectors. To do this, include contents to the upsert() call.For Python, the contents field accepts both strings and bytes. For C++, the contents field only accepts bytes. All contents are encoded to bytes and encrypted before storage using the index key, and will be returned as bytes when retrieved with get().
Copy
Ask AI
# Items to add to the encrypted indexitems = [ {"id": "item_1", "vector": [0.1, 0.2, 0.3, 0.4], "contents": "Hello!"}, {"id": "item_2", "vector": [0.5, 0.6, 0.7, 0.8], "contents": "World!"}, {"id": "item_3", "vector": [0.9, 0.10, 0.11, 0.12], "contents": "Cyborg!"}]# Add items to the encrypted indexindex.upsert(items)
CyborgDB also supports metadata storage, retrieval and filtering. To add metadata to an item, include metadata in the upsert() call.All metadata fields will be encrypted using the index key.
This feature is only available in Python. To use it, use pip install cyborgdb-core[embeddings] or pip install cyborgdb-core[embeddings]
If you provided an embedding_model during index creation, you can automatically generate embeddings for items by providing contents to the upsert() call:
Python
Copy
Ask AI
# ... index creation and embedding model setupembedding_model = "all-MiniLM-L6-v2"index = client.create_index( index_name="my_index", index_key=index_key, index_config=index_config, embedding_model=embedding_model)# Items to add to the encrypted indexitems = [ {"id": "item_1", "contents": "Hello, World!"}, {"id": "item_2", "contents": "Hello, Cyborg!"}]# Add items to the encrypted indexindex.upsert(items)
In this example, the embedding_model will automatically generate embeddings for the contents field. Note that contents must be a string. It will also be converted to bytes for encrypted item storage.This feature uses sentence-transformers for embedding generation. You can use any model from the HuggingFace Model Hub that is compatible with sentence-transformers.