mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
workflow webapp result modification
This commit is contained in:
parent
d239e6bf0f
commit
db3f38bc2b
@ -10,6 +10,7 @@ import { useBoolean } from 'ahooks'
|
|||||||
import { HashtagIcon } from '@heroicons/react/24/solid'
|
import { HashtagIcon } from '@heroicons/react/24/solid'
|
||||||
// import PromptLog from '@/app/components/app/chat/log'
|
// import PromptLog from '@/app/components/app/chat/log'
|
||||||
import { Markdown } from '@/app/components/base/markdown'
|
import { Markdown } from '@/app/components/base/markdown'
|
||||||
|
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
|
||||||
import Loading from '@/app/components/base/loading'
|
import Loading from '@/app/components/base/loading'
|
||||||
import Toast from '@/app/components/base/toast'
|
import Toast from '@/app/components/base/toast'
|
||||||
import AudioBtn from '@/app/components/base/audio-btn'
|
import AudioBtn from '@/app/components/base/audio-btn'
|
||||||
@ -25,6 +26,7 @@ import EditReplyModal from '@/app/components/app/annotation/edit-annotation-moda
|
|||||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||||
import WorkflowProcessItem from '@/app/components/base/chat/chat/answer/workflow-process'
|
import WorkflowProcessItem from '@/app/components/base/chat/chat/answer/workflow-process'
|
||||||
import type { WorkflowProcess } from '@/app/components/base/chat/types'
|
import type { WorkflowProcess } from '@/app/components/base/chat/types'
|
||||||
|
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
||||||
|
|
||||||
const MAX_DEPTH = 3
|
const MAX_DEPTH = 3
|
||||||
|
|
||||||
@ -34,7 +36,7 @@ export type IGenerationItemProps = {
|
|||||||
className?: string
|
className?: string
|
||||||
isError: boolean
|
isError: boolean
|
||||||
onRetry: () => void
|
onRetry: () => void
|
||||||
content: string
|
content: any
|
||||||
messageId?: string | null
|
messageId?: string | null
|
||||||
conversationId?: string
|
conversationId?: string
|
||||||
isLoading?: boolean
|
isLoading?: boolean
|
||||||
@ -288,12 +290,21 @@ const GenerationItem: FC<IGenerationItemProps> = ({
|
|||||||
{workflowProcessData && (
|
{workflowProcessData && (
|
||||||
<WorkflowProcessItem grayBg data={workflowProcessData} expand={workflowProcessData.expand} />
|
<WorkflowProcessItem grayBg data={workflowProcessData} expand={workflowProcessData.expand} />
|
||||||
)}
|
)}
|
||||||
{isError
|
{isError && (
|
||||||
? <div className='text-gray-400 text-sm'>{t('share.generation.batchFailed.outputPlaceholder')}</div>
|
<div className='text-gray-400 text-sm'>{t('share.generation.batchFailed.outputPlaceholder')}</div>
|
||||||
: (
|
)}
|
||||||
<Markdown content={content} />
|
{!isError && (typeof content === 'string') && (
|
||||||
)}
|
<Markdown content={content} />
|
||||||
|
)}
|
||||||
|
{!isError && (typeof content !== 'string') && (
|
||||||
|
<CodeEditor
|
||||||
|
readOnly
|
||||||
|
title={<div/>}
|
||||||
|
language={CodeLanguage.json}
|
||||||
|
value={content}
|
||||||
|
isJSONStringifyBeauty
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -314,7 +325,10 @@ const GenerationItem: FC<IGenerationItemProps> = ({
|
|||||||
isDisabled={isError || !messageId}
|
isDisabled={isError || !messageId}
|
||||||
className={cn(isMobile && '!px-1.5', 'space-x-1')}
|
className={cn(isMobile && '!px-1.5', 'space-x-1')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
copy(content)
|
if (typeof content === 'string')
|
||||||
|
copy(content)
|
||||||
|
else
|
||||||
|
copy(JSON.stringify(content))
|
||||||
Toast.notify({ type: 'success', message: t('common.actionMsg.copySuccessfully') })
|
Toast.notify({ type: 'success', message: t('common.actionMsg.copySuccessfully') })
|
||||||
}}>
|
}}>
|
||||||
<Clipboard className='w-3.5 h-3.5' />
|
<Clipboard className='w-3.5 h-3.5' />
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import type { PromptConfig } from '@/models/debug'
|
|||||||
import type { InstalledApp } from '@/models/explore'
|
import type { InstalledApp } from '@/models/explore'
|
||||||
import type { ModerationService } from '@/models/common'
|
import type { ModerationService } from '@/models/common'
|
||||||
import { TransferMethod, type VisionFile, type VisionSettings } from '@/types/app'
|
import { TransferMethod, type VisionFile, type VisionSettings } from '@/types/app'
|
||||||
import { BlockEnum, NodeRunningStatus, WorkflowRunningStatus } from '@/app/components/workflow/types'
|
import { NodeRunningStatus, WorkflowRunningStatus } from '@/app/components/workflow/types'
|
||||||
import type { WorkflowProcess } from '@/app/components/base/chat/types'
|
import type { WorkflowProcess } from '@/app/components/base/chat/types'
|
||||||
|
|
||||||
export type IResultProps = {
|
export type IResultProps = {
|
||||||
@ -71,9 +71,9 @@ const Result: FC<IResultProps> = ({
|
|||||||
setRespondingFalse()
|
setRespondingFalse()
|
||||||
}, [controlStopResponding])
|
}, [controlStopResponding])
|
||||||
|
|
||||||
const [completionRes, doSetCompletionRes] = useState('')
|
const [completionRes, doSetCompletionRes] = useState<any>('')
|
||||||
const completionResRef = useRef('')
|
const completionResRef = useRef<any>()
|
||||||
const setCompletionRes = (res: string) => {
|
const setCompletionRes = (res: any) => {
|
||||||
completionResRef.current = res
|
completionResRef.current = res
|
||||||
doSetCompletionRes(res)
|
doSetCompletionRes(res)
|
||||||
}
|
}
|
||||||
@ -191,7 +191,6 @@ const Result: FC<IResultProps> = ({
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
if (isWorkflow) {
|
if (isWorkflow) {
|
||||||
let outputsExisted = false
|
|
||||||
sendWorkflowMessage(
|
sendWorkflowMessage(
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
@ -224,10 +223,6 @@ const Result: FC<IResultProps> = ({
|
|||||||
} as any
|
} as any
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
if (data.node_type === BlockEnum.LLM && data.outputs.text)
|
|
||||||
setCompletionRes(data.outputs.text)
|
|
||||||
if (data.node_type === BlockEnum.End && data.outputs)
|
|
||||||
outputsExisted = true
|
|
||||||
},
|
},
|
||||||
onWorkflowFinished: ({ data }) => {
|
onWorkflowFinished: ({ data }) => {
|
||||||
if (isTimeout)
|
if (isTimeout)
|
||||||
@ -239,13 +234,15 @@ const Result: FC<IResultProps> = ({
|
|||||||
clearInterval(runId)
|
clearInterval(runId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!outputsExisted) {
|
|
||||||
notify({ type: 'info', message: 'Outputs not existed.' })
|
|
||||||
setCompletionRes('')
|
|
||||||
}
|
|
||||||
setWorkflowProccessData(produce(getWorkflowProccessData()!, (draft) => {
|
setWorkflowProccessData(produce(getWorkflowProccessData()!, (draft) => {
|
||||||
draft.status = data.error ? WorkflowRunningStatus.Failed : WorkflowRunningStatus.Succeeded
|
draft.status = data.error ? WorkflowRunningStatus.Failed : WorkflowRunningStatus.Succeeded
|
||||||
}))
|
}))
|
||||||
|
if (!data.outputs)
|
||||||
|
setCompletionRes('')
|
||||||
|
else if (Object.keys(data.outputs).length > 1)
|
||||||
|
setCompletionRes(data.outputs)
|
||||||
|
else
|
||||||
|
setCompletionRes(data.outputs[Object.keys(data.outputs)[0]])
|
||||||
setRespondingFalse()
|
setRespondingFalse()
|
||||||
setMessageId(tempMessageId)
|
setMessageId(tempMessageId)
|
||||||
onCompleted(getCompletionRes(), taskId, true)
|
onCompleted(getCompletionRes(), taskId, true)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user