mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
add query to vec2doc
This commit is contained in:
+11
-2
@@ -17,7 +17,7 @@ class VectorStoreToDocument_DocumentLoaders implements INode {
|
||||
constructor() {
|
||||
this.label = 'VectorStore To Document'
|
||||
this.name = 'vectorStoreToDocument'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'Document'
|
||||
this.icon = 'vectorretriever.svg'
|
||||
this.category = 'Document Loaders'
|
||||
@@ -29,6 +29,14 @@ class VectorStoreToDocument_DocumentLoaders implements INode {
|
||||
name: 'vectorStore',
|
||||
type: 'VectorStore'
|
||||
},
|
||||
{
|
||||
label: 'Query',
|
||||
name: 'query',
|
||||
type: 'string',
|
||||
description: 'Query to retrieve documents from vector database. If not specified, user question will be used',
|
||||
optional: true,
|
||||
acceptVariable: true
|
||||
},
|
||||
{
|
||||
label: 'Minimum Score (%)',
|
||||
name: 'minScore',
|
||||
@@ -56,11 +64,12 @@ class VectorStoreToDocument_DocumentLoaders implements INode {
|
||||
async init(nodeData: INodeData, input: string): Promise<any> {
|
||||
const vectorStore = nodeData.inputs?.vectorStore as VectorStore
|
||||
const minScore = nodeData.inputs?.minScore as number
|
||||
const query = nodeData.inputs?.query as string
|
||||
const output = nodeData.outputs?.output as string
|
||||
|
||||
const topK = (vectorStore as any)?.k ?? 4
|
||||
|
||||
const docs = await vectorStore.similaritySearchWithScore(input, topK)
|
||||
const docs = await vectorStore.similaritySearchWithScore(query ?? input, topK)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('\x1b[94m\x1b[1m\n*****VectorStore Documents*****\n\x1b[0m\x1b[0m')
|
||||
// eslint-disable-next-line no-console
|
||||
|
||||
Reference in New Issue
Block a user