Bugfix/stream custom tool return direct (#3003)

stream custom tool return direct
This commit is contained in:
Henry Heng
2024-08-12 18:35:15 +01:00
committed by GitHub
parent f57dc2477f
commit b9f0ec3a3f
4 changed files with 44 additions and 1 deletions
@@ -18,7 +18,7 @@ class CustomTool_Tools implements INode {
constructor() {
this.label = 'Custom Tool'
this.name = 'customTool'
this.version = 1.0
this.version = 2.0
this.type = 'CustomTool'
this.icon = 'customtool.svg'
this.category = 'Tools'
@@ -29,6 +29,13 @@ class CustomTool_Tools implements INode {
name: 'selectedTool',
type: 'asyncOptions',
loadMethod: 'listTools'
},
{
label: 'Return Direct',
name: 'returnDirect',
description: 'Return the output of the tool directly to the user',
type: 'boolean',
optional: true
}
]
this.baseClasses = [this.type, 'Tool', ...getBaseClasses(DynamicStructuredTool)]
@@ -66,6 +73,7 @@ class CustomTool_Tools implements INode {
const customToolName = nodeData.inputs?.customToolName as string
const customToolDesc = nodeData.inputs?.customToolDesc as string
const customToolSchema = nodeData.inputs?.customToolSchema as string
const customToolReturnDirect = nodeData.inputs?.returnDirect as boolean
const appDataSource = options.appDataSource as DataSource
const databaseEntities = options.databaseEntities as IDatabaseEntity
@@ -97,6 +105,7 @@ class CustomTool_Tools implements INode {
let dynamicStructuredTool = new DynamicStructuredTool(obj)
dynamicStructuredTool.setVariables(variables)
dynamicStructuredTool.setFlowObject(flow)
dynamicStructuredTool.returnDirect = customToolReturnDirect
return dynamicStructuredTool
} catch (e) {