LangChain Kinetica Settings Configuration
Posted: Nov 14, 2024.
KineticaSettings is a configuration class in LangChain that helps you set up and manage connections to Kinetica, a vector database with similarity search capabilities. This guide will show you how to properly configure and use KineticaSettings in your LangChain applications.
What is KineticaSettings?
KineticaSettings is a configuration class that encapsulates all the necessary parameters to establish a connection with a Kinetica database and customize its vector search behavior. It handles connection details like host, port, credentials, as well as vector search-specific settings like the distance metric to use.
Reference
Here are the main configuration parameters available in KineticaSettings:
Parameter | Description | Default |
---|---|---|
host | URL of the Kinetica server | 'http://127.0.0.1' |
port | Port number for the connection | 9191 |
username | Username for authentication | None |
password | Password for authentication | None |
database | Name of the database to use | 'langchain' |
table | Name of the table to store vectors | 'langchain_kinetica_embeddings' |
metric | Distance metric for similarity search (l2, cosine, etc) | 'l2' |
How to use KineticaSettings
Here are some common ways to configure and use KineticaSettings:
Basic Configuration
The simplest way to create a KineticaSettings instance is with default values:
Custom Connection Configuration
For connecting to a specific Kinetica instance:
Database and Table Configuration
To specify custom database and table names:
Using with Environment Variables
A common pattern is to load configuration from environment variables:
Using with Vector Store
KineticaSettings is typically used when initializing a Kinetica vector store:
Customizing Search Metric
You can configure the distance metric used for similarity search:
Best Practices
-
Environment Variables: Store sensitive information like credentials in environment variables rather than hardcoding them.
-
Connection Reuse: Create a helper function to generate your settings to ensure consistent configuration across your application:
- Error Handling: When using KineticaSettings, wrap the initialization in try-except blocks to handle potential configuration errors:
KineticaSettings provides a clean and organized way to manage your Kinetica database configuration in LangChain applications. By following these patterns and best practices, you can ensure reliable and secure connections to your vector database.
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.