Reference
srvdb.integrations.llamaindex.SrvDBVectorStore
LlamaIndex vector store over a SrvDB database.
class srvdb.integrations.llamaindex.SrvDBVectorStore(database, **kwargs)Parameters
Section titled “Parameters”-
database : database object An open database whose dimension matches the node embeddings.
-
**kwargs : Any Passed to LlamaIndex’s
BasePydanticVectorStore.
Raises
Section titled “Raises”-
ImportError On import, when
llama-index-coreis not installed; install withpip install "srvdb[llamaindex]". -
ValueError From
add: a node has no embedding or the wrong dimension. Fromquery: noquery_embedding, orsimilarity_top_kbelow 1. -
NotImplementedError A filter uses an operator other than EQ, NE, GT, GTE, LT, LTE, IN, NIN.
-
OSError, RuntimeError Passed through from the underlying database.
- Methods:
add(nodes),delete(ref_doc_id),delete_nodes(node_ids=None, filters=None),query(VectorStoreQuery). Property:client(the database object).stores_textis True. - Nodes must carry embeddings; LlamaIndex computes them before
add. Existing node ids are replaced. MetadataFilterssupport EQ, NE, GT, GTE, LT, LTE, IN and NIN with AND, OR and NOT. Filters,node_idsanddoc_idsrun inside SrvDB (see Filtered search), so a query returnssimilarity_top_knodes whenever that many match; a key containing a dot falls back to filtering search results. A missing key matches only NE and NIN. More than 10,000node_idsordoc_idsraiseValueError; so do an empty nested filter group, IN or NIN with a string value, and EQ or NE with a list value.deleteby document id scans every record, O(n).- Durability: every write calls
save()before it returns. - Thread safety: as thread-safe as the underlying database. The adapter makes no network calls.
Examples
Section titled “Examples”import srvdbfrom llama_index.core.schema import TextNodefrom llama_index.core.vector_stores.types import VectorStoreQueryfrom srvdb.integrations.llamaindex import SrvDBVectorStore
v = [1.0] + [0.0] * 127w = [0.0, 1.0] + [0.0] * 126store = SrvDBVectorStore(srvdb.create("./vectors", dimension=128))store.add([TextNode(id_="a", text="red apple", embedding=v), TextNode(id_="b", text="blue sky", embedding=w)])result = store.query(VectorStoreQuery(query_embedding=v, similarity_top_k=1))print(result.ids)# ['a']See also
Section titled “See also”srvdb.integrations.langchain.SrvDBVectorStore: LangChainVectorStoreover a SrvDB database.srvdb.open: Open an existing database by path.
Was this page helpful? Tell us in Discussions.