-
{title}
+
{title}
{titleTooltip &&
}
diff --git a/web/app/components/workflow/nodes/agent/node.tsx b/web/app/components/workflow/nodes/agent/node.tsx
index 948a9ef0d2..cef0a4330b 100644
--- a/web/app/components/workflow/nodes/agent/node.tsx
+++ b/web/app/components/workflow/nodes/agent/node.tsx
@@ -8,11 +8,33 @@ import type { ToolIconProps } from './components/tool-icon'
import { ToolIcon } from './components/tool-icon'
import useConfig from './use-config'
import { useTranslation } from 'react-i18next'
-import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
+import { FormTypeEnum, ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
+import { useModelList } from '@/app/components/header/account-setting/model-provider-page/hooks'
+
+const useAllModel = () => {
+ const { data: textGeneration } = useModelList(ModelTypeEnum.textGeneration)
+ const { data: moderation } = useModelList(ModelTypeEnum.moderation)
+ const { data: rerank } = useModelList(ModelTypeEnum.rerank)
+ const { data: speech2text } = useModelList(ModelTypeEnum.speech2text)
+ const { data: textEmbedding } = useModelList(ModelTypeEnum.textEmbedding)
+ const { data: tts } = useModelList(ModelTypeEnum.tts)
+ const models = useMemo(() => {
+ return textGeneration
+ .concat(moderation)
+ .concat(rerank)
+ .concat(speech2text)
+ .concat(textEmbedding)
+ .concat(tts)
+ }, [textGeneration, moderation, rerank, speech2text, textEmbedding, tts])
+ if (!textGeneration || !moderation || !rerank || !speech2text || !textEmbedding || !tts)
+ return undefined
+ return models
+}
const AgentNode: FC
> = (props) => {
const { inputs, currentStrategy } = useConfig(props.id, props.data)
const { t } = useTranslation()
+ const modelList = useAllModel()
const models = useMemo(() => {
if (!inputs) return []
// if selected, show in node
@@ -73,7 +95,7 @@ const AgentNode: FC> = (props) => {
{inputs.agent_strategy_label}
: }
- {models.length > 0 && 0 && modelList &&
{t('workflow.nodes.agent.model')}
}
@@ -81,7 +103,8 @@ const AgentNode: FC> = (props) => {
{models.map((model) => {
return > = (props) => {
- const { inputs, setInputs, currentStrategy, formData, onFormChange } = useConfig(props.id, props.data)
+ const {
+ inputs,
+ setInputs,
+ currentStrategy,
+ formData,
+ onFormChange,
+
+ isShowSingleRun,
+ hideSingleRun,
+ runningStatus,
+ handleRun,
+ handleStop,
+ runResult,
+ runInputData,
+ setRunInputData,
+ varInputs,
+ } = useConfig(props.id, props.data)
const { t } = useTranslation()
+ const nodeInfo = useMemo(() => {
+ if (!runResult)
+ return
+ return formatTracing([runResult], t)[0]
+ }, [runResult, t])
+ const logsParams = useLogs()
+ const singleRunForms = (() => {
+ const forms: FormProps[] = []
+
+ if (varInputs.length > 0) {
+ forms.push(
+ {
+ label: t(`${i18nPrefix}.singleRun.variable`)!,
+ inputs: varInputs,
+ values: runInputData,
+ onChange: setRunInputData,
+ },
+ )
+ }
+
+ return forms
+ })()
+
return
+ {
+ isShowSingleRun && (
+ }
+ />
+ )
+ }
}
diff --git a/web/app/components/workflow/nodes/agent/use-config.ts b/web/app/components/workflow/nodes/agent/use-config.ts
index fcd1bed5aa..a1f96e33a2 100644
--- a/web/app/components/workflow/nodes/agent/use-config.ts
+++ b/web/app/components/workflow/nodes/agent/use-config.ts
@@ -21,26 +21,6 @@ const useConfig = (id: string, payload: AgentNodeType) => {
inputs.agent_strategy_provider_name || '',
)
- // single run
- const agentInputKey = `${id}.input_selector`
- const {
- isShowSingleRun,
- showSingleRun,
- hideSingleRun,
- toVarInputs,
- runningStatus,
- handleRun,
- handleStop,
- runInputData,
- setRunInputData,
- runResult,
- } = useOneStepRun
({
- id,
- data: inputs,
- defaultRunInputData: {
- [agentInputKey]: [''],
- },
- })
const currentStrategy = strategyProvider.data?.declaration.strategies.find(
str => str.identity.name === inputs.agent_strategy_name,
)
@@ -70,6 +50,36 @@ const useConfig = (id: string, payload: AgentNodeType) => {
agent_parameters: res,
})
}
+
+ // single run
+ const {
+ isShowSingleRun,
+ showSingleRun,
+ hideSingleRun,
+ toVarInputs,
+ runningStatus,
+ handleRun,
+ handleStop,
+ runInputData,
+ setRunInputData,
+ runResult,
+ getInputVars,
+ } = useOneStepRun({
+ id,
+ data: inputs,
+ defaultRunInputData: {},
+ })
+ const allVarStrArr = (() => {
+ const arr = ['']
+
+ return arr
+ })()
+ const varInputs = (() => {
+ const vars = getInputVars(allVarStrArr)
+
+ return vars
+ })()
+
return {
readOnly,
inputs,
@@ -92,7 +102,7 @@ const useConfig = (id: string, payload: AgentNodeType) => {
runInputData,
setRunInputData,
runResult,
- agentInputKey,
+ varInputs,
}
}
diff --git a/web/app/components/workflow/run/node.tsx b/web/app/components/workflow/run/node.tsx
index 4d27c9bb4c..9efd03df7a 100644
--- a/web/app/components/workflow/run/node.tsx
+++ b/web/app/components/workflow/run/node.tsx
@@ -78,10 +78,10 @@ const NodePanel: FC = ({
setCollapseState(!nodeInfo.expand)
}, [nodeInfo.expand, setCollapseState])
- const isIterationNode = nodeInfo.node_type === BlockEnum.Iteration
- const isRetryNode = hasRetryNode(nodeInfo.node_type) && nodeInfo.retryDetail
- const isAgentNode = nodeInfo.node_type === BlockEnum.Agent
- const isToolNode = nodeInfo.node_type === BlockEnum.Tool
+ const isIterationNode = nodeInfo.node_type === BlockEnum.Iteration && nodeInfo.details?.length
+ const isRetryNode = hasRetryNode(nodeInfo.node_type) && nodeInfo.retryDetail?.length
+ const isAgentNode = nodeInfo.node_type === BlockEnum.Agent && nodeInfo.agentLog?.length
+ const isToolNode = nodeInfo.node_type === BlockEnum.Tool && nodeInfo.agentLog?.length
return (
diff --git a/web/app/components/workflow/run/result-panel.tsx b/web/app/components/workflow/run/result-panel.tsx
index f977987785..a198b2ff6d 100644
--- a/web/app/components/workflow/run/result-panel.tsx
+++ b/web/app/components/workflow/run/result-panel.tsx
@@ -57,10 +57,10 @@ const ResultPanel: FC
= ({
handleShowAgentOrToolLog,
}) => {
const { t } = useTranslation()
- const isIterationNode = nodeInfo?.node_type === BlockEnum.Iteration
- const isRetryNode = hasRetryNode(nodeInfo?.node_type) && nodeInfo?.retryDetail
- const isAgentNode = nodeInfo?.node_type === BlockEnum.Agent
- const isToolNode = nodeInfo?.node_type === BlockEnum.Tool
+ const isIterationNode = nodeInfo?.node_type === BlockEnum.Iteration && nodeInfo?.details?.length
+ const isRetryNode = hasRetryNode(nodeInfo?.node_type) && nodeInfo?.retryDetail?.length
+ const isAgentNode = nodeInfo?.node_type === BlockEnum.Agent && nodeInfo?.agentLog?.length
+ const isToolNode = nodeInfo?.node_type === BlockEnum.Tool && nodeInfo?.agentLog?.length
return (