Skip to content

Commit

Permalink
Feature/Custom Tool OverrideConfig (FlowiseAI#1979)
Browse files Browse the repository at this point in the history
add ability to override custom tool
  • Loading branch information
HenryHengZJ authored Mar 18, 2024
1 parent cd4c659 commit bb7373e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/components/nodes/tools/CustomTool/CustomTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class CustomTool_Tools implements INode {
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const selectedToolId = nodeData.inputs?.selectedTool as string
const customToolFunc = nodeData.inputs?.customToolFunc as string
const customToolName = nodeData.inputs?.customToolName as string
const customToolDesc = nodeData.inputs?.customToolDesc as string
const customToolSchema = nodeData.inputs?.customToolSchema as string

const appDataSource = options.appDataSource as DataSource
const databaseEntities = options.databaseEntities as IDatabaseEntity
Expand All @@ -80,6 +83,12 @@ class CustomTool_Tools implements INode {
code: tool.func
}
if (customToolFunc) obj.code = customToolFunc
if (customToolName) obj.name = customToolName
if (customToolDesc) obj.description = customToolDesc
if (customToolSchema) {
const zodSchemaFunction = new Function('z', `return ${customToolSchema}`)
obj.schema = zodSchemaFunction(z)
}

const variables = await getVars(appDataSource, databaseEntities, nodeData)

Expand Down

0 comments on commit bb7373e

Please sign in to comment.