AWS Lakechain
Project Lakechain 是一个基于 AWS Cloud Development Kit (CDK) 的框架,允许使用基础设施即代码在 AWS 上表达和部署可扩展的文档处理管道。它强调管道的模块化和可扩展性,并提供 60 多个即用型组件,用于原型化可立即扩展到数百万文档的复杂处理管道。
Lakechain 提供的 Qdrant 存储连接器可将其他中间件生成的向量嵌入上传到 Qdrant 集合中。
要使用 Qdrant 存储连接器,请将其导入您的 CDK 堆栈,并将其连接到提供文档嵌入的数据源。
您需要通过指定引用包含 API 密钥的AWS Secrets Manager密钥来为连接器指定 Qdrant API 密钥。
import { QdrantStorageConnector } from '@project-lakechain/qdrant-storage-connector';
import { CacheStorage } from '@project-lakechain/core';
class Stack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string) {
const cache = new CacheStorage(this, 'Cache');
const qdrantApiKey = secrets.Secret.fromSecretNameV2(
this,
'QdrantApiKey',
process.env.QDRANT_API_KEY_SECRET_NAME as string
);
const connector = new QdrantStorageConnector.Builder()
.withScope(this)
.withIdentifier('QdrantStorageConnector')
.withCacheStorage(cache)
.withSource(source) // 👈 Specify a data source
.withApiKey(qdrantApiKey)
.withCollectionName('{collection_name}')
.withUrl('https://xyz-example.eu-central.aws.cloud.qdrant.io:6333')
.build();
}
}
当处理的文档是文本文档时,您可以选择将文档的文本存储在 Qdrant 有效负载中。为此,您可以使用 withStoreText
和 withTextKey
选项。如果文档不是文本,则此选项将被忽略。
const connector = new QdrantStorageConnector.Builder()
.withScope(this)
.withIdentifier('QdrantStorageConnector')
.withCacheStorage(cache)
.withSource(source)
.withApiKey(qdrantApiKey)
.withCollectionName('{collection_name}')
.withStoreText(true)
.withTextKey('my-content')
.withUrl('https://xyz-example.eu-central.aws.cloud.qdrant.io:6333')
.build();
由于 Qdrant 支持每个点有多个向量,您可以使用 withVectorName
选项指定一个。连接器默认为未命名(默认)向量。
const connector = new QdrantStorageConnector.Builder()
.withScope(this)
.withIdentifier('QdrantStorageConnector')
.withCacheStorage(cache)
.withSource(source)
.withApiKey(qdrantApiKey)
.withCollectionName('collection_name')
.withVectorName('my-vector-name')
.withUrl('https://xyz-example.eu-central.aws.cloud.qdrant.io:6333')
.build();