AWS 数据湖链
项目湖链 是一个基于 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();
