mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-23 09:00:28 +03:00
update query engine tool
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { VectorStoreIndex } from 'llamaindex'
|
||||
import { BaseQueryEngine } from 'llamaindex'
|
||||
|
||||
class QueryEngine_Tools implements INode {
|
||||
label: string
|
||||
@@ -16,7 +16,7 @@ class QueryEngine_Tools implements INode {
|
||||
constructor() {
|
||||
this.label = 'QueryEngine Tool'
|
||||
this.name = 'queryEngineToolLlamaIndex'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'QueryEngineTool'
|
||||
this.icon = 'queryEngineTool.svg'
|
||||
this.category = 'Tools'
|
||||
@@ -25,9 +25,9 @@ class QueryEngine_Tools implements INode {
|
||||
this.baseClasses = [this.type]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Vector Store Index',
|
||||
name: 'vectorStoreIndex',
|
||||
type: 'VectorStoreIndex'
|
||||
label: 'Base QueryEngine',
|
||||
name: 'baseQueryEngine',
|
||||
type: 'BaseQueryEngine'
|
||||
},
|
||||
{
|
||||
label: 'Tool Name',
|
||||
@@ -45,20 +45,15 @@ class QueryEngine_Tools implements INode {
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const vectorStoreIndex = nodeData.inputs?.vectorStoreIndex as VectorStoreIndex
|
||||
const baseQueryEngine = nodeData.inputs?.baseQueryEngine as BaseQueryEngine
|
||||
const toolName = nodeData.inputs?.toolName as string
|
||||
const toolDesc = nodeData.inputs?.toolDesc as string
|
||||
const queryEngineTool = {
|
||||
queryEngine: vectorStoreIndex.asQueryEngine({
|
||||
preFilters: {
|
||||
...(vectorStoreIndex as any).metadatafilter
|
||||
}
|
||||
}),
|
||||
queryEngine: baseQueryEngine,
|
||||
metadata: {
|
||||
name: toolName,
|
||||
description: toolDesc
|
||||
},
|
||||
vectorStoreIndex
|
||||
}
|
||||
}
|
||||
|
||||
return queryEngineTool
|
||||
|
||||
Reference in New Issue
Block a user