Setup
Launch openGauss Container
Install langchain-opengauss
- openGauss ≥ 7.0.0
- Python ≥ 3.8
- psycopg2-binary
Credentials
Using your openGauss CredentialsInitialization
Manage vector store
Add items to vector store
Update items in vector store
Delete items from vector store
Query vector store
Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.Query directly
Performing a simple similarity search can be done as follows:- TODO: Edit and then run code cell to generate output
Query by turning into retriever
You can also transform the vector store into a retriever for easier usage in your chains.- TODO: Edit and then run code cell to generate output
Usage for retrieval-augmented generation
For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:Configuration
Connection Settings
Parameter | Default | Description |
---|---|---|
host | localhost | Database server address |
port | 8888 | Database connection port |
user | gaussdb | Database username |
password | - | Complex password string |
database | postgres | Default database name |
min_connections | 1 | Connection pool minimum size |
max_connections | 5 | Connection pool maximum size |
table_name | langchain_docs | Name of the table for storing vector data and metadata |
index_type | IndexType.HNSW | Vector index algorithm type. Options: HNSW or IVFFLAT\nDefault is HNSW. |
vector_type | VectorType.vector | Type of vector representation to use. Default is Vector. |
distance_strategy | DistanceStrategy.COSINE | Vector similarity metric to use for retrieval. Options: euclidean (L2 distance), cosine (angular distance, ideal for text embeddings), manhattan (L1 distance for sparse data), negative_inner_product (dot product for normalized vectors).\n Default is cosine. |
embedding_dimension | 1536 | Dimensionality of the vector embeddings. |
Supported Combinations
Vector Type | Dimensions | Index Types | Supported Distance Strategies |
---|---|---|---|
vector | ≤2000 | HNSW/IVFFLAT | COSINE/EUCLIDEAN/MANHATTAN/INNER_PROD |
Performance Optimization
Index Tuning Guidelines
HNSW Parameters:m
: 16-100 (balance between recall and memory)ef_construction
: 64-1000 (must be > 2*m)
Connection Pooling
Limitations
bit
andsparsevec
vector types currently in development- Maximum vector dimensions: 2000 for
vector
type