AWS Lakechain
Project Lakechain 是一个基于 AWS 云开发工具包 (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();