Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Fix: workflow result display (#5299)

KVOJJJin61ebcd8adb20
diff --git a/web/app/components/share/text-generation/result/index.tsx b/web/app/components/share/text-generation/result/index.tsx
index 90119a8aa4b..b0c20f3b85b 100644
--- a/web/app/components/share/text-generation/result/index.tsx
+++ b/web/app/components/share/text-generation/result/index.tsx
@@ -265,18 +265,29 @@ const Result: FC<IResultProps> = ({
return
if (data.error) {
notify({ type: 'error', message: data.error })
+ setWorkflowProccessData(produce(getWorkflowProccessData()!, (draft) => {
+ draft.status = WorkflowRunningStatus.Failed
+ }))
setRespondingFalse()
onCompleted(getCompletionRes(), taskId, false)
isEnd = true
return
}
setWorkflowProccessData(produce(getWorkflowProccessData()!, (draft) => {
- draft.status = data.error ? WorkflowRunningStatus.Failed : WorkflowRunningStatus.Succeeded
+ draft.status = WorkflowRunningStatus.Succeeded
}))
- if (!data.outputs)
+ if (!data.outputs) {
setCompletionRes('')
- else
+ }
+ else {
setCompletionRes(data.outputs)
+ const isStringOutput = Object.keys(data.outputs).length === 1 && typeof data.outputs[Object.keys(data.outputs)[0]] === 'string'
+ if (isStringOutput) {
+ setWorkflowProccessData(produce(getWorkflowProccessData()!, (draft) => {
+ draft.resultText = data.outputs[Object.keys(data.outputs)[0]]
+ }))
+ }
+ }
setRespondingFalse()
setMessageId(tempMessageId)
onCompleted(getCompletionRes(), taskId, true)
diff --git a/web/app/components/workflow/hooks/use-workflow-run.ts b/web/app/components/workflow/hooks/use-workflow-run.ts
index bb2758625b5..f31137196fc 100644
--- a/web/app/components/workflow/hooks/use-workflow-run.ts
+++ b/web/app/components/workflow/hooks/use-workflow-run.ts
@@ -179,11 +179,17 @@ export const useWorkflowRun = () => {
setWorkflowRunningData,
} = workflowStore.getState()
+ const isStringOutput = Object.keys(data.outputs).length === 1 && typeof data.outputs[Object.keys(data.outputs)[0]] === 'string'
+
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
draft.result = {
...draft.result,
...data,
} as any
+ if (isStringOutput) {
+ draft.resultTabActive = true
+ draft.resultText = data.outputs[Object.keys(data.outputs)[0]]
+ }
}))
prevNodeId = ''