Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Add content and metadata key for qdrant #2997

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions packages/components/nodes/vectorstores/Qdrant/Qdrant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Qdrant_VectorStores implements INode {
constructor() {
this.label = 'Qdrant'
this.name = 'qdrant'
this.version = 3.0
this.version = 4.0
this.type = 'Qdrant'
this.icon = 'qdrant.png'
this.category = 'Vector Stores'
Expand Down Expand Up @@ -85,6 +85,24 @@ class Qdrant_VectorStores implements INode {
default: 1536,
additionalParams: true
},
{
label: 'Content Key',
name: 'contentPayloadKey',
description: 'The key for storing text. Default to `content`',
type: 'string',
default: 'content',
optional: true,
additionalParams: true
},
{
label: 'Metadata Key',
name: 'metadataPayloadKey',
description: 'The key for storing metadata. Default to `metadata`',
type: 'string',
default: 'metadata',
optional: true,
additionalParams: true
},
{
label: 'Upsert Batch Size',
name: 'batchSize',
Expand Down Expand Up @@ -168,6 +186,8 @@ class Qdrant_VectorStores implements INode {
const qdrantVectorDimension = nodeData.inputs?.qdrantVectorDimension
const recordManager = nodeData.inputs?.recordManager
const _batchSize = nodeData.inputs?.batchSize
const contentPayloadKey = nodeData.inputs?.contentPayloadKey || 'content'
const metadataPayloadKey = nodeData.inputs?.metadataPayloadKey || 'metadata'

const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const qdrantApiKey = getCredentialParam('qdrantApiKey', credentialData, nodeData)
Expand Down Expand Up @@ -197,7 +217,9 @@ class Qdrant_VectorStores implements INode {
size: qdrantVectorDimension ? parseInt(qdrantVectorDimension, 10) : 1536,
distance: qdrantSimilarity ?? 'Cosine'
}
}
},
contentPayloadKey,
metadataPayloadKey
}

try {
Expand All @@ -220,8 +242,8 @@ class Qdrant_VectorStores implements INode {
id: documentOptions?.ids?.length ? documentOptions?.ids[idx] : uuid(),
vector: embedding,
payload: {
content: documents[idx].pageContent,
metadata: documents[idx].metadata,
[contentPayloadKey]: documents[idx].pageContent,
[metadataPayloadKey]: documents[idx].metadata,
customPayload: documentOptions?.customPayload?.length ? documentOptions?.customPayload[idx] : undefined
}
}))
Expand Down Expand Up @@ -367,6 +389,8 @@ class Qdrant_VectorStores implements INode {
const output = nodeData.outputs?.output as string
const topK = nodeData.inputs?.topK as string
let queryFilter = nodeData.inputs?.qdrantFilter
const contentPayloadKey = nodeData.inputs?.contentPayloadKey || 'content'
const metadataPayloadKey = nodeData.inputs?.metadataPayloadKey || 'metadata'

const k = topK ? parseFloat(topK) : 4

Expand All @@ -383,7 +407,9 @@ class Qdrant_VectorStores implements INode {

const dbConfig: QdrantLibArgs = {
client,
collectionName
collectionName,
contentPayloadKey,
metadataPayloadKey
}

const retrieverConfig: RetrieverConfig = {
Expand Down
Loading