mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
feat: add tool params node & tool params add array type (#2824)
* add tool params node * add tool params enum * node response * tool add array type params * fix tool params * fix * fix * fix
This commit is contained in:
@@ -118,6 +118,7 @@ export enum FlowNodeTypeEnum {
|
||||
queryExtension = 'cfr',
|
||||
tools = 'tools',
|
||||
stopTool = 'stopTool',
|
||||
toolParams = 'toolParams',
|
||||
lafModule = 'lafModule',
|
||||
ifElseNode = 'ifElseNode',
|
||||
variableUpdate = 'variableUpdate',
|
||||
|
@@ -186,6 +186,9 @@ export type DispatchNodeResponseType = {
|
||||
|
||||
// form input
|
||||
formInputResult?: string;
|
||||
|
||||
// tool params
|
||||
toolParamsResult?: Record<string, any>;
|
||||
};
|
||||
|
||||
export type DispatchNodeResultType<T = {}> = {
|
||||
|
@@ -234,7 +234,8 @@ export const getReferenceVariableValue = ({
|
||||
nodes: RuntimeNodeItemType[];
|
||||
variables: Record<string, any>;
|
||||
}) => {
|
||||
if (!isReferenceValue(value)) {
|
||||
const nodeIds = nodes.map((node) => node.nodeId);
|
||||
if (!isReferenceValue(value, nodeIds)) {
|
||||
return value;
|
||||
}
|
||||
const sourceNodeId = value[0];
|
||||
|
@@ -33,17 +33,19 @@ import { LoopNode } from './system/loop/loop';
|
||||
import { LoopStartNode } from './system/loop/loopStart';
|
||||
import { LoopEndNode } from './system/loop/loopEnd';
|
||||
import { FormInputNode } from './system/interactive/formInput';
|
||||
import { ToolParamsNode } from './system/toolParams';
|
||||
|
||||
const systemNodes: FlowNodeTemplateType[] = [
|
||||
AiChatModule,
|
||||
TextEditorNode,
|
||||
AssignedAnswerModule,
|
||||
DatasetSearchModule,
|
||||
DatasetConcatModule,
|
||||
ToolModule,
|
||||
StopToolNode,
|
||||
ClassifyQuestionModule,
|
||||
ContextExtractModule,
|
||||
DatasetConcatModule,
|
||||
ToolModule,
|
||||
ToolParamsNode,
|
||||
StopToolNode,
|
||||
ReadFilesNode,
|
||||
HttpNode468,
|
||||
AiQueryExtension,
|
||||
|
20
packages/global/core/workflow/template/system/toolParams.ts
Normal file
20
packages/global/core/workflow/template/system/toolParams.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { FlowNodeTypeEnum } from '../../node/constant';
|
||||
import { FlowNodeTemplateType } from '../../type/node';
|
||||
import { FlowNodeTemplateTypeEnum } from '../../constants';
|
||||
import { getHandleConfig } from '../utils';
|
||||
import { i18nT } from '../../../../../web/i18n/utils';
|
||||
|
||||
export const ToolParamsNode: FlowNodeTemplateType = {
|
||||
id: FlowNodeTypeEnum.toolParams,
|
||||
templateType: FlowNodeTemplateTypeEnum.ai,
|
||||
flowNodeType: FlowNodeTypeEnum.toolParams,
|
||||
sourceHandle: getHandleConfig(true, true, true, true),
|
||||
targetHandle: getHandleConfig(true, true, true, true),
|
||||
avatar: 'core/workflow/template/toolParams',
|
||||
name: i18nT('workflow:tool_params_config'),
|
||||
intro: i18nT('workflow:intro_tool_params_config'),
|
||||
version: '4811',
|
||||
isTool: true,
|
||||
inputs: [],
|
||||
outputs: []
|
||||
};
|
1
packages/global/core/workflow/type/io.d.ts
vendored
1
packages/global/core/workflow/type/io.d.ts
vendored
@@ -50,6 +50,7 @@ export type FlowNodeInputItemType = InputComponentPropsType & {
|
||||
description?: string; // field desc
|
||||
required?: boolean;
|
||||
toolDescription?: string; // If this field is not empty, it is entered as a tool
|
||||
enum?: string;
|
||||
|
||||
// render components params
|
||||
canEdit?: boolean; // dynamic inputs
|
||||
|
@@ -297,8 +297,8 @@ export const formatEditorVariablePickerIcon = (
|
||||
}));
|
||||
};
|
||||
|
||||
export const isReferenceValue = (value: any): boolean => {
|
||||
return Array.isArray(value) && value.length === 2 && typeof value[0] === 'string';
|
||||
export const isReferenceValue = (value: any, nodeIds: string[]): boolean => {
|
||||
return Array.isArray(value) && value.length === 2 && nodeIds.includes(value[0]);
|
||||
};
|
||||
|
||||
export const getElseIFLabel = (i: number) => {
|
||||
|
Reference in New Issue
Block a user