LangChain
simplevecdb.integrations.langchain.SimpleVecDBVectorStore
Bases: VectorStore
LangChain-compatible wrapper for SimpleVecDB.
Source code in src/simplevecdb/integrations/langchain.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
embeddings
property
LangChain VectorStore.embeddings contract.
The base class exposes the embedding model via this property and
framework code (as_retriever(), tag generation, etc.) reads it.
Storing the field as self.embedding (singular) without overriding
this property would silently return None to those callers.
from_texts(texts, embedding, metadatas=None, db_path=':memory:', collection_name='default', **kwargs)
classmethod
Initialize from texts (embeds them automatically).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
list[str]
|
List of texts to add. |
required |
embedding
|
Embeddings
|
LangChain Embeddings model. |
required |
metadatas
|
list[dict] | None
|
Optional list of metadata dicts. |
None
|
db_path
|
str
|
Path to SQLite database. |
':memory:'
|
collection_name
|
str
|
Name of the collection to use. |
'default'
|
**kwargs
|
Any
|
Additional arguments for VectorDB. |
{}
|
Returns:
| Type | Description |
|---|---|
SimpleVecDBVectorStore
|
Initialized SimpleVecDBVectorStore. |
Source code in src/simplevecdb/integrations/langchain.py
add_texts(texts, metadatas=None, **kwargs)
Add texts (embed if no pre-computed). Returns IDs as str.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
Iterable[str]
|
Iterable of texts to add. |
required |
metadatas
|
list[dict] | None
|
Optional list of metadata dicts. |
None
|
**kwargs
|
Any
|
Additional arguments (e.g., ids). |
{}
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of document IDs. |
Source code in src/simplevecdb/integrations/langchain.py
similarity_search(query, k=4, **kwargs)
Search by text query (auto-embeds).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Text query string. |
required |
k
|
int
|
Number of results to return. |
4
|
**kwargs
|
Any
|
Additional arguments (e.g., filter). |
{}
|
Returns:
| Type | Description |
|---|---|
list[Document]
|
List of LangChain Documents. |
Source code in src/simplevecdb/integrations/langchain.py
similarity_search_with_score(query, k=4, **kwargs)
Return with scores (distances).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Text query string. |
required |
k
|
int
|
Number of results to return. |
4
|
**kwargs
|
Any
|
Additional arguments (e.g., filter). |
{}
|
Returns:
| Type | Description |
|---|---|
list[tuple[Document, float]]
|
List of (Document, score) tuples. |
Source code in src/simplevecdb/integrations/langchain.py
delete(ids=None, **kwargs)
Delete documents by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
list[str] | None
|
List of document IDs to delete. |
None
|
**kwargs
|
Any
|
Unused. |
{}
|
Source code in src/simplevecdb/integrations/langchain.py
max_marginal_relevance_search(query, k=4, fetch_k=constants.DEFAULT_FETCH_K, lambda_mult=0.5, **kwargs)
Max marginal relevance search.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Text query string. |
required |
k
|
int
|
Number of results to return. |
4
|
fetch_k
|
int
|
Number of candidates to fetch. |
DEFAULT_FETCH_K
|
lambda_mult
|
float
|
Diversity trade-off (unused in core currently). |
0.5
|
**kwargs
|
Any
|
Additional arguments (e.g., filter). |
{}
|
Returns:
| Type | Description |
|---|---|
list[Document]
|
List of LangChain Documents. |
Source code in src/simplevecdb/integrations/langchain.py
keyword_search(query, k=4, **kwargs)
Return BM25-ranked documents without requiring embeddings.
Source code in src/simplevecdb/integrations/langchain.py
hybrid_search(query, k=4, **kwargs)
Blend BM25 + vector rankings using Reciprocal Rank Fusion.
Source code in src/simplevecdb/integrations/langchain.py
LlamaIndex
simplevecdb.integrations.llamaindex.SimpleVecDBLlamaStore
Bases: BasePydanticVectorStore
LlamaIndex-compatible wrapper for SimpleVecDB.
Source code in src/simplevecdb/integrations/llamaindex.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
client
property
Return the underlying client (our VectorDB).
store_text
property
Whether the store keeps text content.
migrate_node_id_metadata()
Backfill _simplevecdb_node_id for documents inserted before 2.6.0.
Pre-2.6.0 versions did not persist the LlamaIndex node_id into
document metadata, so delete(ref_doc_id) could not find the
right row after a process restart. This helper walks every
document in the underlying collection and stamps the internal DB
id as the node_id for any row that lacks _simplevecdb_node_id
metadata. Idempotent — already-stamped rows are skipped, so a
retry after a partial run converges.
Limitation
Pre-2.6.0 rows never had their original LlamaIndex node_id
persisted, so the backfill stamps str(doc_id) (the integer DB
rowid) as the node_id. After migration:
delete(str(doc_id))works against migrated rows.delete(<original-llama-uuid>)still cannot find these rows; the original ids were never written to disk and cannot be recovered. Re-indexing the upstream documents is the only way to restore stable node ids that match the LlamaIndex side.
Atomicity: the underlying update_metadata issues one
transaction per chunk of 500 rows. A process kill between chunks
leaves the migration half-done; calling this method again will
finish it (the per-row idempotency guard skips already-stamped
rows).
Returns:
| Type | Description |
|---|---|
int
|
Number of documents updated. |
Source code in src/simplevecdb/integrations/llamaindex.py
add(nodes, **kwargs)
Add nodes with embeddings.
The node_id is persisted into the document's metadata under
_simplevecdb_node_id so it survives process restarts. The
in-memory _id_map is also populated as a fast cache for the
current session.
Source code in src/simplevecdb/integrations/llamaindex.py
delete(ref_doc_id, **delete_kwargs)
Delete by ref_doc_id (node ID).
First consults the in-memory _id_map for the current session;
on a miss (typically after a restart) falls back to a metadata
query against _simplevecdb_node_id so deletion is reliable
across process boundaries.
Source code in src/simplevecdb/integrations/llamaindex.py
delete_nodes(node_ids=None, filters=None, **delete_kwargs)
Delete nodes from vector store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_ids
|
list[str] | None
|
List of node IDs to delete. |
None
|
filters
|
MetadataFilters | None
|
Metadata filters. Currently unsupported — passing a
non-None |
None
|
**delete_kwargs
|
Any
|
Unused. |
{}
|
Source code in src/simplevecdb/integrations/llamaindex.py
query(query, **kwargs)
Support dense, keyword, or hybrid lookups based on the requested mode.