DB2VS vector store.
| Name | Type | Description |
|---|---|---|
embedding_function* | Callable[[str], list[float]] | Embeddings | The embedding backend used to generate vectors for stored texts and queries |
table_name* | str | DB2 table name |
client | Connection | None | Default: None |
distance_strategy | DistanceStrategy | Default: DistanceStrategy.EUCLIDEAN_DISTANCE |
query | str | None | Default: 'What is a Db2 database' |
params | dict[str, Any] | None | Default: None |
connection_args | dict[str, Any] | None | Default: None |
text_field | str | Default: 'text' |
To use, you should have:
langchain_db2 python package installedpip install -U langchain-db2
# or using uv
uv add langchain-db2Create a Vector Store instance with ibm_db_dbi.Connection object
from langchain_db2 import DB2VS
db2vs = DB2VS(
embedding_function=embeddings, table_name=table_name, client=db_client
)
Create a Vector Store instance with connection_args
from langchain_db2 import DB2VS
db2vs = DB2VS(
embedding_function=embeddings,
table_name=table_name,
connection_args={
"database": "<DATABASE>",
"host": "<HOST>",
"port": "<PORT>",
"username": "<USERNAME>",
"password": "<PASSWORD>",
"security": False,
},
)Existing DB2 connection. Required if connection_args is not provided
Similarity metric used by Db2 VECTOR_DISTANCE when
ranking results
Probe text used once to infer embedding dimension
Extra options
Connection parameters used when client is not supplied.
Expected keys: {"database": str, "host": str, "port": str, "username": str, "password": str, "security": bool}
Column name for the raw text (CLOB)