mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 01:01:11 +03:00
add override customToolFunc
This commit is contained in:
@@ -36,7 +36,7 @@ class CustomTool_Tools implements INode {
|
|||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
loadMethods = {
|
loadMethods = {
|
||||||
async listTools(nodeData: INodeData, options: ICommonObject): Promise<INodeOptionsValue[]> {
|
async listTools(_: INodeData, options: ICommonObject): Promise<INodeOptionsValue[]> {
|
||||||
const returnData: INodeOptionsValue[] = []
|
const returnData: INodeOptionsValue[] = []
|
||||||
|
|
||||||
const appDataSource = options.appDataSource as DataSource
|
const appDataSource = options.appDataSource as DataSource
|
||||||
@@ -60,8 +60,9 @@ class CustomTool_Tools implements INode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(nodeData: INodeData, input: string, options: ICommonObject): Promise<any> {
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
const selectedToolId = nodeData.inputs?.selectedTool as string
|
const selectedToolId = nodeData.inputs?.selectedTool as string
|
||||||
|
const customToolFunc = nodeData.inputs?.customToolFunc as string
|
||||||
|
|
||||||
const appDataSource = options.appDataSource as DataSource
|
const appDataSource = options.appDataSource as DataSource
|
||||||
const databaseEntities = options.databaseEntities as IDatabaseEntity
|
const databaseEntities = options.databaseEntities as IDatabaseEntity
|
||||||
@@ -78,6 +79,7 @@ class CustomTool_Tools implements INode {
|
|||||||
schema: z.object(convertSchemaToZod(tool.schema)),
|
schema: z.object(convertSchemaToZod(tool.schema)),
|
||||||
code: tool.func
|
code: tool.func
|
||||||
}
|
}
|
||||||
|
if (customToolFunc) obj.code = customToolFunc
|
||||||
return new DynamicStructuredTool(obj)
|
return new DynamicStructuredTool(obj)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e)
|
throw new Error(e)
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ const ToolDialog = ({ show, dialogProps, onUseTemplate, onCancel, onConfirm }) =
|
|||||||
Javascript Function
|
Javascript Function
|
||||||
<TooltipWithParser
|
<TooltipWithParser
|
||||||
style={{ marginLeft: 10 }}
|
style={{ marginLeft: 10 }}
|
||||||
title='Function to execute when tool is being used. You can use properties specified in Output Schema as variables. For example, if the property is <code>userid</code>, you can use as <code>$userid</code>. Return value must be a string.'
|
title='Function to execute when tool is being used. You can use properties specified in Output Schema as variables. For example, if the property is <code>userid</code>, you can use as <code>$userid</code>. Return value must be a string. You can also override the code from API by following this <a target="_blank" href="https://docs.flowiseai.com/tools/custom-tool#override-function-from-api">guide</a>'
|
||||||
/>
|
/>
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
Reference in New Issue
Block a user