feat: support select field as tool output (#2798)

* feat: support select field as tool output

* defaultOutput
This commit is contained in:
papapatrick
2024-09-26 14:37:06 +08:00
committed by GitHub
parent 1cf76ee7df
commit cb6fe9d0da
13 changed files with 323 additions and 46 deletions

View File

@@ -47,6 +47,16 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
const plugin = await getChildAppRuntimeById(pluginId);
const outputFilterMap = plugin.nodes
.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginOutput)!
.inputs.reduce(
(acc, cur) => {
acc[cur.key] = cur.isToolOutput === false ? false : true;
return acc;
},
{} as Record<string, boolean>
);
const runtimeNodes = storeNodes2RuntimeNodes(
plugin.nodes,
getWorkflowEntryNodeIds(plugin.nodes)
@@ -130,7 +140,17 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
tokens: 0
}
],
[DispatchNodeResponseKeyEnum.toolResponses]: output?.pluginOutput ? output.pluginOutput : {},
[DispatchNodeResponseKeyEnum.toolResponses]: output?.pluginOutput
? Object.keys(output.pluginOutput)
.filter((key) => outputFilterMap[key])
.reduce(
(acc, key) => {
acc[key] = output.pluginOutput![key];
return acc;
},
{} as Record<string, any>
)
: {},
...(output ? output.pluginOutput : {})
};
};