diff --git a/web/app/components/plugins/plugin-detail-panel/multiple-tool-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/multiple-tool-selector/index.tsx index f2626a9b41..35c7842c0e 100644 --- a/web/app/components/plugins/plugin-detail-panel/multiple-tool-selector/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/multiple-tool-selector/index.tsx @@ -26,6 +26,7 @@ type Props = { supportVariables?: boolean nodeOutputVars: NodeOutPutVar[], availableNodes: Node[], + nodeId?: string } const MultipleToolSelector = ({ @@ -40,6 +41,7 @@ const MultipleToolSelector = ({ supportVariables, nodeOutputVars, availableNodes, + nodeId, }: Props) => { const { t } = useTranslation() const enabledCount = value.filter(item => item.enabled).length @@ -130,6 +132,7 @@ const MultipleToolSelector = ({ <> = ({ value, @@ -91,6 +92,7 @@ const ToolSelector: FC = ({ onPanelShowStateChange, nodeOutputVars, availableNodes, + nodeId = '', }) => { const { t } = useTranslation() const [isShow, onShowChange] = useState(false) @@ -414,6 +416,7 @@ const ToolSelector: FC = ({ schemas={paramsFormSchemas as any} nodeOutputVars={nodeOutputVars} availableNodes={availableNodes} + nodeId={nodeId} /> )} diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx index 38d83542e6..3780658564 100644 --- a/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx @@ -6,14 +6,20 @@ import { } from '@remixicon/react' import Tooltip from '@/app/components/base/tooltip' import Switch from '@/app/components/base/switch' +import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector' import ModelParameterModal from '@/app/components/plugins/plugin-detail-panel/model-selector' import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' import type { Node } from 'reactflow' -import type { NodeOutPutVar, ValueSelector } from '@/app/components/workflow/types' +import type { + NodeOutPutVar, + ValueSelector, + Var, +} from '@/app/components/workflow/types' import type { ToolVarInputs } from '@/app/components/workflow/nodes/tool/types' import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types' +import { VarType } from '@/app/components/workflow/types' import cn from '@/utils/classnames' type Props = { @@ -22,6 +28,7 @@ type Props = { schemas: any[] nodeOutputVars: NodeOutPutVar[], availableNodes: Node[], + nodeId: string } const ReasoningConfigForm: React.FC = ({ @@ -30,17 +37,15 @@ const ReasoningConfigForm: React.FC = ({ schemas, nodeOutputVars, availableNodes, + nodeId, }) => { const { t } = useTranslation() const language = useLanguage() - const handleFormChange = (key: string, val: string | boolean) => { - onChange({ ...value, [key]: val }) - } const handleAutomatic = (key: string, val: any) => { onChange({ ...value, [key]: { - ...value[key], + value: val ? null : value[key]?.value, auto: val ? 1 : 0, }, }) @@ -60,13 +65,13 @@ const ReasoningConfigForm: React.FC = ({ const handleNotMixedTypeChange = useCallback((variable: string) => { return (varValue: ValueSelector | string, varKindType: VarKindType) => { const newValue = produce(value, (draft: ToolVarInputs) => { - const target = draft[variable] + const target = draft[variable].value if (target) { target.type = varKindType target.value = varValue } else { - draft[variable] = { + draft[variable].value = { type: varKindType, value: varValue, } @@ -78,12 +83,12 @@ const ReasoningConfigForm: React.FC = ({ const handleMixedTypeChange = useCallback((variable: string) => { return (itemValue: string) => { const newValue = produce(value, (draft: ToolVarInputs) => { - const target = draft[variable] + const target = draft[variable].value if (target) { target.value = itemValue } else { - draft[variable] = { + draft[variable].value = { type: VarKindType.mixed, value: itemValue, } @@ -95,7 +100,7 @@ const ReasoningConfigForm: React.FC = ({ const handleFileChange = useCallback((variable: string) => { return (varValue: ValueSelector | string) => { const newValue = produce(value, (draft: ToolVarInputs) => { - draft[variable] = { + draft[variable].value = { type: VarKindType.variable, value: varValue, } @@ -103,7 +108,6 @@ const ReasoningConfigForm: React.FC = ({ onChange(newValue) } }, [value, onChange]) - const handleAppChange = useCallback((variable: string) => { return (app: { app_id: string @@ -111,7 +115,7 @@ const ReasoningConfigForm: React.FC = ({ files?: any[] }) => { const newValue = produce(value, (draft: ToolVarInputs) => { - draft[variable] = app as any + draft[variable].value = app as any }) onChange(newValue) } @@ -119,8 +123,8 @@ const ReasoningConfigForm: React.FC = ({ const handleModelChange = useCallback((variable: string) => { return (model: any) => { const newValue = produce(value, (draft: ToolVarInputs) => { - draft[variable] = { - ...draft[variable], + draft[variable].value = { + ...draft[variable].value, ...model, } as any }) @@ -188,33 +192,31 @@ const ReasoningConfigForm: React.FC = ({ placeholderClassName='!leading-[21px]' /> )} */} - {/* {(isNumber || isSelect) && ( + {(isNumber || isSelect) && ( varPayload.type === schema._type : undefined} + availableVars={isSelect ? nodeOutputVars : undefined} schema={schema} /> - )} */} - {/* {isFile && ( + )} + {isFile && ( varPayload.type === VarType.file || varPayload.type === VarType.arrayFile} /> - )} */} + )} {isAppSelector && ( void nodeOutputVars?: NodeOutPutVar[], availableNodes?: Node[], + nodeId?: string } type CustomSchema = Omit & { type: Type } & Field @@ -46,7 +47,7 @@ type MultipleToolSelectorSchema = CustomSchema<'array[tools]'> type CustomField = ToolSelectorSchema | MultipleToolSelectorSchema export const AgentStrategy = memo((props: AgentStrategyProps) => { - const { strategy, onStrategyChange, formSchema, formValue, onFormValueChange, nodeOutputVars, availableNodes } = props + const { strategy, onStrategyChange, formSchema, formValue, onFormValueChange, nodeOutputVars, availableNodes, nodeId } = props const { t } = useTranslation() const defaultModel = useDefaultModel(ModelTypeEnum.textGeneration) const renderI18nObject = useRenderI18nObject() @@ -155,6 +156,7 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => { > { return ( > = (props) => { onFormValueChange={onFormChange} nodeOutputVars={availableVars} availableNodes={availableNodesWithParent} + nodeId={props.id} />