From 17f0dde2c23a23b71c8573ecc13eac36a560384b Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 7 May 2025 14:21:02 +0800 Subject: [PATCH] feat: more params for tools params support --- .../components/before-run-form/index.tsx | 2 - .../_base/components/workflow-panel/index.tsx | 15 ++- .../workflow-panel/last-run/index.tsx | 9 +- .../workflow-panel/last-run/use-last-run.ts | 62 +++++++++++- .../nodes/_base/hooks/use-one-step-run.ts | 24 ++--- .../nodes/agent/use-single-run-form-params.ts | 3 - .../components/workflow/nodes/tool/panel.tsx | 36 +------ .../workflow/nodes/tool/use-config.ts | 97 +------------------ .../nodes/tool/use-get-data-for-check-more.ts | 20 ++++ .../nodes/tool/use-single-run-form-params.ts | 89 +++++++++++++++++ .../components/workflow/run/result-panel.tsx | 2 +- 11 files changed, 201 insertions(+), 158 deletions(-) create mode 100644 web/app/components/workflow/nodes/tool/use-get-data-for-check-more.ts create mode 100644 web/app/components/workflow/nodes/tool/use-single-run-form-params.ts diff --git a/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx b/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx index 89c2fa7dd3..bb150c778a 100644 --- a/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx @@ -79,8 +79,6 @@ const BeforeRunForm: FC = ({ }) => { const { t } = useTranslation() - // useWhyDidYouUpdate('BeforeRunForm', { nodeName, nodeType, toolIcon, onHide, onRun, onStop, runningStatus, result, forms, showSpecialResultPanel, filteredExistVarForms, existVarValuesInForms, ...restResultPanelParams }) - const isFinished = runningStatus === NodeRunningStatus.Succeeded || runningStatus === NodeRunningStatus.Failed || runningStatus === NodeRunningStatus.Exception const isRunning = runningStatus === NodeRunningStatus.Running const isFileLoaded = (() => { diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx index 619dead7ab..3ad7e851f0 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx @@ -44,7 +44,7 @@ import { hasRetryNode, } from '@/app/components/workflow/utils' import Tooltip from '@/app/components/base/tooltip' -import type { Node } from '@/app/components/workflow/types' +import { BlockEnum, type Node } from '@/app/components/workflow/types' import { useStore as useAppStore } from '@/app/components/app/store' import { useStore } from '@/app/components/workflow/store' import Tab, { TabType } from './tab' @@ -53,6 +53,7 @@ import useLastRun from './last-run/use-last-run' import BeforeRunForm from '../before-run-form' import { debounce } from 'lodash-es' import { NODES_EXTRA_DATA } from '@/app/components/workflow/constants' +import { useLogs } from '@/app/components/workflow/run/hooks' type BasePanelProps = { children: ReactNode @@ -150,6 +151,7 @@ const BasePanel: FC = ({ tabType, setTabType, singleRunParams, + nodeInfo, setRunInputData, hasLastRunData, handleSingleRun, @@ -162,6 +164,14 @@ const BasePanel: FC = ({ defaultRunInputData: NODES_EXTRA_DATA[data.type]?.defaultRunInputData || {}, }) + const logParams = useLogs() + const passedLogParams = (() => { + if ([BlockEnum.Tool, BlockEnum.Agent, BlockEnum.Iteration, BlockEnum.Loop].includes(data.type)) + return logParams + + return {} + })() + if (isShowSingleRun) { return (
= ({ onRun={handleRunWithParams} onStop={handleStop} {...singleRunParams!} + {...passedLogParams} existVarValuesInForms={getExistVarValuesInForms(singleRunParams?.forms as any)} filteredExistVarForms={getFilteredExistVarForms(singleRunParams?.forms as any)} result={<>} @@ -319,6 +330,8 @@ const BasePanel: FC = ({ canSingleRun={isSupportSingleRun} runningStatus={runningStatus} onSingleRunClicked={handleSingleRun} + nodeInfo={nodeInfo} + {...passedLogParams} /> )}
diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/index.tsx b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/index.tsx index ff6acba013..5702353a69 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/index.tsx @@ -1,4 +1,5 @@ 'use client' +import type { ResultPanelProps } from '@/app/components/workflow/run/result-panel' import ResultPanel from '@/app/components/workflow/run/result-panel' import { NodeRunningStatus } from '@/app/components/workflow/types' import type { FC } from 'react' @@ -6,21 +7,25 @@ import React from 'react' import NoData from './no-data' import { useLastRun } from '@/service/use-workflow' import { RiLoader2Line } from '@remixicon/react' +import type { NodeTracing } from '@/types/workflow' type Props = { appId: string nodeId: string canSingleRun: boolean + nodeInfo?: NodeTracing runningStatus?: NodeRunningStatus onSingleRunClicked: () => void -} +} & Partial const LastRun: FC = ({ appId, nodeId, canSingleRun, + nodeInfo, runningStatus, onSingleRunClicked, + ...otherResultPanelProps }) => { const isRunning = runningStatus === NodeRunningStatus.Running const { data: runResult, isFetching } = useLastRun(appId, nodeId, !isRunning) @@ -44,6 +49,8 @@ const LastRun: FC = ({
diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts index cda6485477..a1fa623185 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts @@ -12,6 +12,7 @@ import useTemplateTransformSingleRunFormParams from '@/app/components/workflow/n import useQuestionClassifierSingleRunFormParams from '@/app/components/workflow/nodes/question-classifier/use-single-run-form-params' import useParameterExtractorSingleRunFormParams from '@/app/components/workflow/nodes/parameter-extractor/use-single-run-form-params' import useHttpRequestSingleRunFormParams from '@/app/components/workflow/nodes/http/use-single-run-form-params' +import useToolSingleRunFormParams from '@/app/components/workflow/nodes/tool/use-single-run-form-params' import useIterationSingleRunFormParams from '@/app/components/workflow/nodes/iteration/use-single-run-form-params' import useAgentSingleRunFormParams from '@/app/components/workflow/nodes/agent/use-single-run-form-params' import useDocExtractorSingleRunFormParams from '@/app/components/workflow/nodes/document-extractor/use-single-run-form-params' @@ -19,6 +20,10 @@ import useLoopSingleRunFormParams from '@/app/components/workflow/nodes/loop/use import useIfElseSingleRunFormParams from '@/app/components/workflow/nodes/if-else/use-single-run-form-params' import useVariableAggregatorSingleRunFormParams from '@/app/components/workflow/nodes/variable-assigner/use-single-run-form-params' +import useToolGetDataForCheckMore from '@/app/components/workflow/nodes/tool/use-get-data-for-check-more' + +// import +import type { CommonNodeType } from '@/app/components/workflow/types' import { BlockEnum } from '@/app/components/workflow/types' import { useNodesSyncDraft, @@ -31,7 +36,7 @@ const singleRunFormParamsHooks: Record = { [BlockEnum.TemplateTransform]: useTemplateTransformSingleRunFormParams, [BlockEnum.QuestionClassifier]: useQuestionClassifierSingleRunFormParams, [BlockEnum.HttpRequest]: useHttpRequestSingleRunFormParams, - [BlockEnum.Tool]: undefined, + [BlockEnum.Tool]: useToolSingleRunFormParams, [BlockEnum.ParameterExtractor]: useParameterExtractorSingleRunFormParams, [BlockEnum.Iteration]: useIterationSingleRunFormParams, [BlockEnum.Agent]: useAgentSingleRunFormParams, @@ -56,17 +61,59 @@ const useSingleRunFormParamsHooks = (nodeType: BlockEnum) => { } } +const getDataForCheckMoreHooks: Record = { + [BlockEnum.Tool]: useToolGetDataForCheckMore, + [BlockEnum.LLM]: undefined, + [BlockEnum.KnowledgeRetrieval]: undefined, + [BlockEnum.Code]: undefined, + [BlockEnum.TemplateTransform]: undefined, + [BlockEnum.QuestionClassifier]: undefined, + [BlockEnum.HttpRequest]: undefined, + [BlockEnum.ParameterExtractor]: undefined, + [BlockEnum.Iteration]: undefined, + [BlockEnum.Agent]: undefined, + [BlockEnum.DocExtractor]: undefined, + [BlockEnum.Loop]: undefined, + [BlockEnum.Start]: undefined, + [BlockEnum.IfElse]: undefined, + [BlockEnum.VariableAggregator]: undefined, + [BlockEnum.End]: undefined, + [BlockEnum.Answer]: undefined, + [BlockEnum.VariableAssigner]: undefined, + [BlockEnum.ListFilter]: undefined, + [BlockEnum.IterationStart]: undefined, + [BlockEnum.Assigner]: undefined, + [BlockEnum.LoopStart]: undefined, + [BlockEnum.LoopEnd]: undefined, +} + +const useGetDataForCheckMoreHooks = (nodeType: BlockEnum) => { + return (id: string, payload: CommonNodeType) => { + return getDataForCheckMoreHooks[nodeType]?.({ id, payload }) || { + getData: () => { + return {} + }, + } + } +} + type Params = OneStepRunParams const useLastRun = ({ ...oneStepRunParams }: Params) => { const { handleSyncWorkflowDraft } = useNodesSyncDraft() - + const { + getData: getDataForCheckMore, + } = useGetDataForCheckMoreHooks(oneStepRunParams.data.type)(oneStepRunParams.id, oneStepRunParams.data) const { id, data, } = oneStepRunParams - const oneStepRunRes = useOneStepRun(oneStepRunParams) + const oneStepRunRes = useOneStepRun({ + ...oneStepRunParams, + moreDataForCheckValid: getDataForCheckMore(), + }) + const { hideSingleRun, handleRun: doCallRunApi, @@ -77,9 +124,13 @@ const useLastRun = ({ runInputDataRef, setRunInputData, showSingleRun, + runResult, } = oneStepRunRes - const singleRunParams = useSingleRunFormParamsHooks(data.type)({ + const { + nodeInfo, + ...singleRunParams + } = useSingleRunFormParamsHooks(data.type)({ id, payload: data, runInputData, @@ -88,6 +139,7 @@ const useLastRun = ({ setRunInputData, toVarInputs, varSelectorsToVarInputs, + runResult, }) const callRunApi = async (data: Record) => { @@ -115,7 +167,6 @@ const useLastRun = ({ if (!forms || forms.length === 0) return [] - // if (!singleRunParams) const valuesArr = forms.map((form) => { const values: Record = {} form.inputs.forEach(({ variable }) => { @@ -181,6 +232,7 @@ const useLastRun = ({ tabType, setTabType: handleTabClicked, singleRunParams, + nodeInfo, setRunInputData, hasLastRunData, handleSingleRun, diff --git a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts index 10acf2c5b7..accefef961 100644 --- a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts +++ b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts @@ -521,24 +521,6 @@ const useOneStepRun = ({ return varInputs } - const varSelectorsToVarInputs = (valueSelectors: ValueSelector[]): InputVar[] => { - return valueSelectors.map((item) => { - const varInfo = getNodeInfoById(availableNodesIncludeParent, item[0])?.data - return { - type: InputVarType.textInput, - required: true, - label: { - nodeType: varInfo?.type, - nodeName: varInfo?.title || availableNodesIncludeParent[0]?.data.title, // default start node title - variable: isSystemVar(item) ? item.join('.') : item[item.length - 1], - isChatVar: isConversationVar(item), - }, - variable: isSystemVar(item) ? `#${item.join('.')}#` : `${item.join('.')}`, - value_selector: item, - } - }) - } - const getInputVars = (textList: string[]) => { const valueSelectors: ValueSelector[] = [] textList.forEach((text) => { @@ -564,6 +546,12 @@ const useOneStepRun = ({ return varInputs } + const varSelectorsToVarInputs = (valueSelectors: ValueSelector[] | string[]): InputVar[] => { + return valueSelectors.map((item) => { + return getInputVars([`{{#${typeof item === 'string' ? item : item.join('.')}#}}`])[0] + }) + } + return { isShowSingleRun, hideSingleRun, diff --git a/web/app/components/workflow/nodes/agent/use-single-run-form-params.ts b/web/app/components/workflow/nodes/agent/use-single-run-form-params.ts index 3b99f58581..6580315625 100644 --- a/web/app/components/workflow/nodes/agent/use-single-run-form-params.ts +++ b/web/app/components/workflow/nodes/agent/use-single-run-form-params.ts @@ -3,7 +3,6 @@ import type { InputVar, Variable } from '@/app/components/workflow/types' import { useMemo } from 'react' import useNodeCrud from '../_base/hooks/use-node-crud' import type { AgentNodeType } from './types' -import { useLogs } from '../../run/hooks' import { useTranslation } from 'react-i18next' import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form' import { useStrategyInfo } from './use-config' @@ -28,7 +27,6 @@ const useSingleRunFormParams = ({ }: Params) => { const { t } = useTranslation() const { inputs } = useNodeCrud(id, payload) - const logsParams = useLogs() const formData = useMemo(() => { return Object.fromEntries( @@ -72,7 +70,6 @@ const useSingleRunFormParams = ({ return { forms, - logsParams, } } diff --git a/web/app/components/workflow/nodes/tool/panel.tsx b/web/app/components/workflow/nodes/tool/panel.tsx index 85966443d5..5379a1dac5 100644 --- a/web/app/components/workflow/nodes/tool/panel.tsx +++ b/web/app/components/workflow/nodes/tool/panel.tsx @@ -1,5 +1,5 @@ import type { FC } from 'react' -import React, { useMemo } from 'react' +import React from 'react' import { useTranslation } from 'react-i18next' import Split from '../_base/components/split' import type { ToolNodeType } from './types' @@ -11,12 +11,7 @@ import type { NodePanelProps } from '@/app/components/workflow/types' import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form' import ConfigCredential from '@/app/components/tools/setting/build-in/config-credentials' import Loading from '@/app/components/base/loading' -import BeforeRunForm from '@/app/components/workflow/nodes/_base/components/before-run-form' import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' -import ResultPanel from '@/app/components/workflow/run/result-panel' -import { useToolIcon } from '@/app/components/workflow/hooks' -import { useLogs } from '@/app/components/workflow/run/hooks' -import formatToTracingNodeList from '@/app/components/workflow/run/utils/format-log' import StructureOutputItem from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show' import { Type } from '../llm/types' @@ -45,23 +40,9 @@ const Panel: FC> = ({ hideSetAuthModal, handleSaveAuth, isLoading, - isShowSingleRun, - hideSingleRun, - singleRunForms, - runningStatus, - handleRun, - handleStop, - runResult, outputSchema, hasObjectOutput, } = useConfig(id, data) - const toolIcon = useToolIcon(data) - const logsParams = useLogs() - const nodeInfo = useMemo(() => { - if (!runResult) - return null - return formatToTracingNodeList([runResult], t)[0] - }, [runResult, t]) if (isLoading) { return
@@ -180,21 +161,6 @@ const Panel: FC> = ({
- - {isShowSingleRun && ( - } - /> - )} ) } diff --git a/web/app/components/workflow/nodes/tool/use-config.ts b/web/app/components/workflow/nodes/tool/use-config.ts index 38ca5b5195..b83ae8a07f 100644 --- a/web/app/components/workflow/nodes/tool/use-config.ts +++ b/web/app/components/workflow/nodes/tool/use-config.ts @@ -3,17 +3,15 @@ import { useTranslation } from 'react-i18next' import produce from 'immer' import { useBoolean } from 'ahooks' import { useStore } from '../../store' -import { type ToolNodeType, type ToolVarInputs, VarType } from './types' +import type { ToolNodeType, ToolVarInputs } from './types' import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud' import { CollectionType } from '@/app/components/tools/types' import { updateBuiltInToolCredential } from '@/service/tools' import { addDefaultValue, toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema' import Toast from '@/app/components/base/toast' -import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form' import { VarType as VarVarType } from '@/app/components/workflow/types' -import type { InputVar, ValueSelector, Var } from '@/app/components/workflow/types' -import useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-step-run' +import type { InputVar, Var } from '@/app/components/workflow/types' import { useFetchToolsData, useNodesReadOnly, @@ -160,39 +158,8 @@ const useConfig = (id: string, payload: ToolNodeType) => { const isLoading = currTool && (isBuiltIn ? !currCollection : false) - // single run - const [inputVarValues, doSetInputVarValues] = useState>({}) - const setInputVarValues = (value: Record) => { - doSetInputVarValues(value) - // eslint-disable-next-line ts/no-use-before-define - setRunInputData(value) - } - // fill single run form variable with constant value first time - const inputVarValuesWithConstantValue = () => { - const res = produce(inputVarValues, (draft) => { - Object.keys(inputs.tool_parameters).forEach((key: string) => { - const { type, value } = inputs.tool_parameters[key] - if (type === VarType.constant && (value === undefined || value === null)) - draft.tool_parameters[key].value = value - }) - }) - return res - } - - const { - isShowSingleRun, - hideSingleRun, - getInputVars, - runningStatus, - setRunInputData, - handleRun: doHandleRun, - handleStop, - runResult, - } = useOneStepRun({ - id, - data: inputs, - defaultRunInputData: {}, - moreDataForCheckValid: { + const getMoreDataForCheckValid = () => { + return { toolInputsSchema: (() => { const formInputs: InputVar[] = [] toolInputVarSchema.forEach((item: any) => { @@ -208,52 +175,7 @@ const useConfig = (id: string, payload: ToolNodeType) => { notAuthed: isShowAuthBtn, toolSettingSchema, language, - }, - }) - - const hadVarParams = Object.keys(inputs.tool_parameters) - .filter(key => inputs.tool_parameters[key].type !== VarType.constant) - .map(k => inputs.tool_parameters[k]) - - const varInputs = getInputVars(hadVarParams.map((p) => { - if (p.type === VarType.variable) { - // handle the old wrong value not crash the page - if (!(p.value as any).join) - return `{{#${p.value}#}}` - - return `{{#${(p.value as ValueSelector).join('.')}#}}` } - - return p.value as string - })) - - const singleRunForms = (() => { - const forms: FormProps[] = [{ - inputs: varInputs, - values: inputVarValuesWithConstantValue(), - onChange: setInputVarValues, - }] - return forms - })() - - const handleRun = (submitData: Record) => { - const varTypeInputKeys = Object.keys(inputs.tool_parameters) - .filter(key => inputs.tool_parameters[key].type === VarType.variable) - const shouldAdd = varTypeInputKeys.length > 0 - if (!shouldAdd) { - doHandleRun(submitData) - return - } - const addMissedVarData = { ...submitData } - Object.keys(submitData).forEach((key) => { - const value = submitData[key] - varTypeInputKeys.forEach((inputKey) => { - const inputValue = inputs.tool_parameters[inputKey].value as ValueSelector - if (`#${inputValue.join('.')}#` === key) - addMissedVarData[inputKey] = value - }) - }) - doHandleRun(addMissedVarData) } const outputSchema = useMemo(() => { @@ -307,18 +229,9 @@ const useConfig = (id: string, payload: ToolNodeType) => { hideSetAuthModal, handleSaveAuth, isLoading, - isShowSingleRun, - hideSingleRun, - inputVarValues, - varInputs, - setInputVarValues, - singleRunForms, - runningStatus, - handleRun, - handleStop, - runResult, outputSchema, hasObjectOutput, + getMoreDataForCheckValid, } } diff --git a/web/app/components/workflow/nodes/tool/use-get-data-for-check-more.ts b/web/app/components/workflow/nodes/tool/use-get-data-for-check-more.ts new file mode 100644 index 0000000000..a68f12fc37 --- /dev/null +++ b/web/app/components/workflow/nodes/tool/use-get-data-for-check-more.ts @@ -0,0 +1,20 @@ +import type { ToolNodeType } from './types' +import useConfig from './use-config' + +type Params = { + id: string + payload: ToolNodeType, +} + +const useGetDataForCheckMore = ({ + id, + payload, +}: Params) => { + const { getMoreDataForCheckValid } = useConfig(id, payload) + + return { + getData: getMoreDataForCheckValid, + } +} + +export default useGetDataForCheckMore diff --git a/web/app/components/workflow/nodes/tool/use-single-run-form-params.ts b/web/app/components/workflow/nodes/tool/use-single-run-form-params.ts new file mode 100644 index 0000000000..144e6c306c --- /dev/null +++ b/web/app/components/workflow/nodes/tool/use-single-run-form-params.ts @@ -0,0 +1,89 @@ +import type { MutableRefObject } from 'react' +import type { InputVar, Variable } from '@/app/components/workflow/types' +import { useCallback, useMemo, useState } from 'react' +import useNodeCrud from '../_base/hooks/use-node-crud' +import { type ToolNodeType, VarType } from './types' +import type { ValueSelector } from '@/app/components/workflow/types' +import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form' +import produce from 'immer' +import type { NodeTracing } from '@/types/workflow' +import { useTranslation } from 'react-i18next' +import formatToTracingNodeList from '@/app/components/workflow/run/utils/format-log' +import { useToolIcon } from '../../hooks' + +type Params = { + id: string, + payload: ToolNodeType, + runInputData: Record + runInputDataRef: MutableRefObject> + getInputVars: (textList: string[]) => InputVar[] + setRunInputData: (data: Record) => void + toVarInputs: (variables: Variable[]) => InputVar[] + runResult: NodeTracing +} +const useSingleRunFormParams = ({ + id, + payload, + getInputVars, + setRunInputData, + runResult, +}: Params) => { + const { t } = useTranslation() + const { inputs } = useNodeCrud(id, payload) + + const hadVarParams = Object.keys(inputs.tool_parameters) + .filter(key => inputs.tool_parameters[key].type !== VarType.constant) + .map(k => inputs.tool_parameters[k]) + const varInputs = getInputVars(hadVarParams.map((p) => { + if (p.type === VarType.variable) { + // handle the old wrong value not crash the page + if (!(p.value as any).join) + return `{{#${p.value}#}}` + + return `{{#${(p.value as ValueSelector).join('.')}#}}` + } + + return p.value as string + })) + const [inputVarValues, doSetInputVarValues] = useState>({}) + const setInputVarValues = useCallback((value: Record) => { + doSetInputVarValues(value) + setRunInputData(value) + }, [setRunInputData]) + + const inputVarValuesWithConstantValue = useCallback(() => { + const res = produce(inputVarValues, (draft) => { + Object.keys(inputs.tool_parameters).forEach((key: string) => { + const { type, value } = inputs.tool_parameters[key] + if (type === VarType.constant && (value === undefined || value === null)) + draft.tool_parameters[key].value = value + }) + }) + return res + }, [inputs.tool_parameters, inputVarValues]) + + const forms = useMemo(() => { + const forms: FormProps[] = [{ + inputs: varInputs, + values: inputVarValuesWithConstantValue(), + onChange: setInputVarValues, + }] + return forms + }, [inputVarValuesWithConstantValue, setInputVarValues, varInputs]) + + const nodeInfo = useMemo(() => { + if (!runResult) + return null + return formatToTracingNodeList([runResult], t)[0] + }, [runResult, t]) + + const toolIcon = useToolIcon(payload) + + return { + forms, + nodeInfo, + toolIcon, + } +} + +export default useSingleRunFormParams diff --git a/web/app/components/workflow/run/result-panel.tsx b/web/app/components/workflow/run/result-panel.tsx index be77f056d6..14260e646b 100644 --- a/web/app/components/workflow/run/result-panel.tsx +++ b/web/app/components/workflow/run/result-panel.tsx @@ -17,7 +17,7 @@ import { LoopLogTrigger } from '@/app/components/workflow/run/loop-log' import { RetryLogTrigger } from '@/app/components/workflow/run/retry-log' import { AgentLogTrigger } from '@/app/components/workflow/run/agent-log' -type ResultPanelProps = { +export type ResultPanelProps = { nodeInfo?: NodeTracing inputs?: string process_data?: string