@@ -3,6 +3,9 @@ import { QdrantClient } from '@qdrant/js-client-rest'
33import { QdrantVectorStore , QdrantLibArgs } from 'langchain/vectorstores/qdrant'
44import { Embeddings } from 'langchain/embeddings/base'
55import { getBaseClasses , getCredentialData , getCredentialParam } from '../../../src/utils'
6+ import { VectorStoreRetrieverInput } from 'langchain/vectorstores/base'
7+
8+ type RetrieverConfig = Partial < VectorStoreRetrieverInput < QdrantVectorStore > >
69
710class Qdrant_Existing_VectorStores implements INode {
811 label : string
@@ -53,7 +56,7 @@ class Qdrant_Existing_VectorStores implements INode {
5356 } ,
5457 {
5558 label : 'Qdrant Collection Cofiguration' ,
56- name : 'qdrantCollectionCofiguration ' ,
59+ name : 'qdrantCollectionConfiguration ' ,
5760 type : 'json' ,
5861 optional : true ,
5962 additionalParams : true
@@ -66,6 +69,14 @@ class Qdrant_Existing_VectorStores implements INode {
6669 type : 'number' ,
6770 additionalParams : true ,
6871 optional : true
72+ } ,
73+ {
74+ label : 'Qdrant Search Filter' ,
75+ name : 'qdrantFilter' ,
76+ description : 'Only return points which satisfy the conditions' ,
77+ type : 'json' ,
78+ additionalParams : true ,
79+ optional : true
6980 }
7081 ]
7182 this . outputs = [
@@ -85,10 +96,12 @@ class Qdrant_Existing_VectorStores implements INode {
8596 async init ( nodeData : INodeData , _ : string , options : ICommonObject ) : Promise < any > {
8697 const qdrantServerUrl = nodeData . inputs ?. qdrantServerUrl as string
8798 const collectionName = nodeData . inputs ?. qdrantCollection as string
88- let qdrantCollectionCofiguration = nodeData . inputs ?. qdrantCollectionCofiguration
99+ let qdrantCollectionConfiguration = nodeData . inputs ?. qdrantCollectionConfiguration
89100 const embeddings = nodeData . inputs ?. embeddings as Embeddings
90101 const output = nodeData . outputs ?. output as string
91102 const topK = nodeData . inputs ?. topK as string
103+ let queryFilter = nodeData . inputs ?. queryFilter
104+
92105 const k = topK ? parseFloat ( topK ) : 4
93106
94107 const credentialData = await getCredentialData ( nodeData . credential ?? '' , options )
@@ -104,16 +117,26 @@ class Qdrant_Existing_VectorStores implements INode {
104117 collectionName
105118 }
106119
107- if ( qdrantCollectionCofiguration ) {
108- qdrantCollectionCofiguration =
109- typeof qdrantCollectionCofiguration === 'object' ? qdrantCollectionCofiguration : JSON . parse ( qdrantCollectionCofiguration )
110- dbConfig . collectionConfig = qdrantCollectionCofiguration
120+ const retrieverConfig : RetrieverConfig = {
121+ k
122+ }
123+
124+ if ( qdrantCollectionConfiguration ) {
125+ qdrantCollectionConfiguration =
126+ typeof qdrantCollectionConfiguration === 'object'
127+ ? qdrantCollectionConfiguration
128+ : JSON . parse ( qdrantCollectionConfiguration )
129+ dbConfig . collectionConfig = qdrantCollectionConfiguration
130+ }
131+
132+ if ( queryFilter ) {
133+ retrieverConfig . filter = typeof queryFilter === 'object' ? queryFilter : JSON . parse ( queryFilter )
111134 }
112135
113136 const vectorStore = await QdrantVectorStore . fromExistingCollection ( embeddings , dbConfig )
114137
115138 if ( output === 'retriever' ) {
116- const retriever = vectorStore . asRetriever ( k )
139+ const retriever = vectorStore . asRetriever ( retrieverConfig )
117140 return retriever
118141 } else if ( output === 'vectorStore' ) {
119142 ; ( vectorStore as any ) . k = k
0 commit comments