Skip to main content
LambdaDB is a serverless AI database for building scalable RAG and agent applications.
This notebook covers how to get started with the LambdaDB vector store in LangChain.

设置

要访问 LambdaDB 向量存储,您需要create a LambdaDB account, get your project credentials, and install the langchain-lambdadb integration package.

凭证

LambdaDB uses project-based authentication with a project URL and API key:
To enable automated tracing of your model calls, set your LangSmith API key:

安装

The LangChain LambdaDB integration lives in the langchain-lambdadb package:
You’ll also need to install an embedding model. For example, to use OpenAI embeddings:

实例化

LambdaDBVectorStore works with existing collections. You must create the collection beforehand with proper vector and text indexes configured.

Key parameters

  • client: LambdaDB client instance (required)
  • collection_name: Name of an existing collection in LambdaDB (required)
  • embedding: Embedding function to use (required)
  • text_field: Name of the text field in documents (default: “text”)
  • vector_field: Name of the vector field in documents (default: “vector”)
  • validate_collection: Whether to validate that the collection exists and is active (default: True)
  • default_consistent_read: Use consistent reads by default for immediate consistency, or eventual consistency for better performance (default: False)

管理向量存储

Add items

Documents have a maximum size of 50KB. The integration automatically batches documents into groups of up to 100 to stay within LambdaDB’s 6MB request limit.

Delete items

Get items by ID


查询向量存储

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.

相似度搜索

Performing a simple similarity search:

Similarity search with scores

If you want to execute a similarity search and receive the corresponding scores:

Similarity search with filtering

LambdaDB supports filtering using query string syntax:
MMR optimizes for both similarity to the query AND diversity among selected documents:

Turn into retriever

You can also transform the vector store into a retriever for easier usage in your chains:
Supported search types:
  • "similarity": Standard similarity search (default)
  • "mmr": Maximal marginal relevance search
  • "similarity_score_threshold": Similarity search with a score threshold

Async operations

LambdaDBVectorStore supports async methods for all operations:
Currently, async methods run synchronously as the LambdaDB client doesn’t support async operations yet.

Consistency control

LambdaDB supports two consistency modes:
  • Eventual consistency (default): Faster performance, but data may be up to ~1 minute stale after writes
  • Consistent reads: Immediate consistency, slight performance impact

Creating from texts

You can create a vector store and populate it with texts in one step:

用于检索增强生成

Here’s a complete example using LambdaDB for RAG:

Key features

Document size limits

  • Maximum document size: 50KB per document
  • The integration validates document sizes and raises an error if exceeded

Batch processing

  • Documents are automatically batched in groups of 100 for upsert operations
  • Stays within LambdaDB’s 6MB request limit

过滤

  • Supports LambdaDB’s query string syntax for metadata filtering
  • Example: filter={"queryString": {"query": "field:value"}}

Search options

  • Similarity search: Find documents similar to a query
  • MMR search: Balance similarity and diversity
  • Score thresholding: Filter results by similarity score
  • Consistent reads: Control read consistency vs. performance trade-off

API 参考

For detailed documentation of all LambdaDBVectorStore features and configurations, head to the API reference.

Additional resources