LangChain Connection Parameters for Vector Databases
Posted: Nov 16, 2024.
When working with cloud vector databases like Baidu VectorDB or Tencent VectorDB in LangChain, you'll need to properly configure the connection parameters. The ConnectionParams
class provides a standardized way to specify these connection details.
What is ConnectionParams?
ConnectionParams
is a utility class in LangChain that encapsulates the connection configuration needed to authenticate and connect to vector databases. It was originally designed for Baidu VectorDB but is also used by other providers like Tencent Cloud VectorDB.
Reference
Here are the key parameters supported by ConnectionParams:
Parameter | Type | Description | Default |
---|---|---|---|
endpoint | str | The server address of the vector database | Required |
api_key | str | API key for authentication | Required |
account | str | Account name for authentication | "root" |
connection_timeout_in_mills | int | Connection timeout in milliseconds | 50000 |
How to use ConnectionParams
Basic Configuration
The most basic usage is to provide the required endpoint and API key:
Custom Timeout Configuration
You can customize the connection timeout if needed:
Using with Baidu VectorDB
Here's how to use ConnectionParams with Baidu's vector database:
Using with Tencent VectorDB
The same ConnectionParams class can be used with Tencent's vector database:
When working with these vector databases, make sure to:
- Have valid credentials (API key and endpoint)
- Properly configure timeouts based on your network conditions
- Keep your API keys secure and never commit them to version control
Remember that the exact configuration needed may vary depending on your specific use case and the vector database service you're using.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.
LangChain DocsJoin 10,000+ subscribers
Every 2 weeks, latest model releases and industry news.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.