mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-17 03:25:57 +08:00
text generation run
This commit is contained in:
parent
0ab525a691
commit
719ef9cef9
@ -4,12 +4,11 @@ import {
|
||||
} from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import cn from '@/utils/classnames'
|
||||
// import Loading from '@/app/components/base/loading'
|
||||
import { Markdown } from '@/app/components/base/markdown'
|
||||
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
|
||||
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
||||
import type { WorkflowProcess } from '@/app/components/base/chat/types'
|
||||
// import { WorkflowRunningStatus } from '@/app/components/workflow/types'
|
||||
import { FileList } from '@/app/components/base/file-uploader'
|
||||
|
||||
const ResultTab = ({
|
||||
data,
|
||||
@ -56,7 +55,16 @@ const ResultTab = ({
|
||||
)}
|
||||
<div className={cn('grow bg-white')}>
|
||||
{currentTab === 'RESULT' && (
|
||||
<Markdown content={data?.resultText || ''} />
|
||||
<>
|
||||
<Markdown content={data?.resultText || ''} />
|
||||
{data?.files?.length && (
|
||||
<FileList
|
||||
files={data?.files}
|
||||
showDeleteAction={false}
|
||||
showDownloadAction
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{currentTab === 'DETAIL' && content && (
|
||||
<CodeEditor
|
||||
|
@ -55,6 +55,7 @@ export type WorkflowProcess = {
|
||||
tracing: NodeTracing[]
|
||||
expand?: boolean // for UI
|
||||
resultText?: string
|
||||
files?: FileEntity[]
|
||||
}
|
||||
|
||||
export type ChatItem = IChatItem & {
|
||||
|
@ -392,7 +392,6 @@ const TextGeneration: FC<IMainProps> = ({
|
||||
image_file_size_limit: appParams?.system_parameters?.image_file_size_limit,
|
||||
})
|
||||
const prompt_variables = userInputsFormToPromptVariables(user_input_form)
|
||||
console.log(prompt_variables)
|
||||
setPromptConfig({
|
||||
prompt_template: '', // placeholder for future
|
||||
prompt_variables,
|
||||
|
@ -20,6 +20,9 @@ import type { WorkflowProcess } from '@/app/components/base/chat/types'
|
||||
import { sleep } from '@/utils'
|
||||
import type { SiteInfo } from '@/models/share'
|
||||
import { TEXT_GENERATION_TIMEOUT_MS } from '@/config'
|
||||
import {
|
||||
getProcessedFilesFromResponse,
|
||||
} from '@/app/components/base/file-uploader/utils'
|
||||
|
||||
export type IResultProps = {
|
||||
isWorkflow: boolean
|
||||
@ -295,6 +298,7 @@ const Result: FC<IResultProps> = ({
|
||||
if (isStringOutput) {
|
||||
setWorkflowProcessData(produce(getWorkflowProcessData()!, (draft) => {
|
||||
draft.resultText = data.outputs[Object.keys(data.outputs)[0]]
|
||||
draft.files = getProcessedFilesFromResponse(data.files || [])
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import TextGenerationImageUploader from '@/app/components/base/image-uploader/te
|
||||
import type { VisionFile, VisionSettings } from '@/types/app'
|
||||
import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader'
|
||||
import { getProcessedFiles } from '@/app/components/base/file-uploader/utils'
|
||||
// import { InputVarType } from '@/app/components/workflow/types'
|
||||
|
||||
export type IRunOnceProps = {
|
||||
siteInfo: SiteInfo
|
||||
|
@ -24,6 +24,9 @@ import {
|
||||
} from '@/service/workflow'
|
||||
import { useFeaturesStore } from '@/app/components/base/features/hooks'
|
||||
import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.player.manager'
|
||||
import {
|
||||
getProcessedFilesFromResponse,
|
||||
} from '@/app/components/base/file-uploader/utils'
|
||||
|
||||
export const useWorkflowRun = () => {
|
||||
const store = useStoreApi()
|
||||
@ -207,6 +210,7 @@ export const useWorkflowRun = () => {
|
||||
draft.result = {
|
||||
...draft.result,
|
||||
...data,
|
||||
files: getProcessedFilesFromResponse(data.files || []),
|
||||
} as any
|
||||
if (isStringOutput) {
|
||||
draft.resultTabActive = true
|
||||
|
@ -1,5 +1,6 @@
|
||||
import {
|
||||
memo,
|
||||
useCallback,
|
||||
useMemo,
|
||||
} from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@ -14,7 +15,7 @@ import {
|
||||
useStore,
|
||||
useWorkflowStore,
|
||||
} from '../store'
|
||||
import { useWorkflowRun } from '../hooks'
|
||||
import { useCheckStartNodeForm, useWorkflowRun } from '../hooks'
|
||||
import type { StartNodeType } from '../nodes/start/types'
|
||||
import { TransferMethod } from '../../base/text-generation/types'
|
||||
import Button from '@/app/components/base/button'
|
||||
@ -55,6 +56,8 @@ const InputsPanel = ({ onRun }: Props) => {
|
||||
return data
|
||||
}, [fileSettings?.image?.enabled, startVariables])
|
||||
|
||||
const { getProcessedInputs } = useCheckStartNodeForm()
|
||||
|
||||
const handleValueChange = (variable: string, v: any) => {
|
||||
const {
|
||||
inputs,
|
||||
@ -73,17 +76,17 @@ const InputsPanel = ({ onRun }: Props) => {
|
||||
}
|
||||
}
|
||||
|
||||
const doRun = () => {
|
||||
const doRun = useCallback(() => {
|
||||
onRun()
|
||||
handleRun({ inputs, files })
|
||||
}
|
||||
handleRun({ inputs: getProcessedInputs(inputs), files })
|
||||
}, [files, getProcessedInputs, handleRun, inputs, onRun])
|
||||
|
||||
const canRun = (() => {
|
||||
const canRun = useMemo(() => {
|
||||
if (files?.some(item => (item.transfer_method as any) === TransferMethod.local_file && !item.upload_file_id))
|
||||
return false
|
||||
|
||||
return true
|
||||
})()
|
||||
}, [files])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -157,6 +157,7 @@ const WorkflowPreview = () => {
|
||||
<ResultText
|
||||
isRunning={workflowRunningData?.result?.status === WorkflowRunningStatus.Running || !workflowRunningData?.result}
|
||||
outputs={workflowRunningData?.resultText}
|
||||
allFiles={workflowRunningData?.result?.files as any}
|
||||
error={workflowRunningData?.result?.error}
|
||||
onClick={() => switchTab('DETAIL')}
|
||||
/>
|
||||
|
@ -5,12 +5,15 @@ import { ImageIndentLeft } from '@/app/components/base/icons/src/vender/line/edi
|
||||
import { Markdown } from '@/app/components/base/markdown'
|
||||
import LoadingAnim from '@/app/components/base/chat/chat/loading-anim'
|
||||
import StatusContainer from '@/app/components/workflow/run/status-container'
|
||||
import { FileList } from '@/app/components/base/file-uploader'
|
||||
import type { FileEntity } from '@/app/components/base/file-uploader/types'
|
||||
|
||||
type ResultTextProps = {
|
||||
isRunning?: boolean
|
||||
outputs?: any
|
||||
error?: string
|
||||
onClick?: () => void
|
||||
allFiles?: FileEntity[]
|
||||
}
|
||||
|
||||
const ResultText: FC<ResultTextProps> = ({
|
||||
@ -18,6 +21,7 @@ const ResultText: FC<ResultTextProps> = ({
|
||||
outputs,
|
||||
error,
|
||||
onClick,
|
||||
allFiles,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
@ -48,6 +52,13 @@ const ResultText: FC<ResultTextProps> = ({
|
||||
{outputs && (
|
||||
<div className='px-4 py-2'>
|
||||
<Markdown content={outputs} />
|
||||
{allFiles?.length && (
|
||||
<FileList
|
||||
files={allFiles}
|
||||
showDeleteAction={false}
|
||||
showDownloadAction
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
@ -6,7 +6,7 @@ import type {
|
||||
import type { Resolution, TransferMethod } from '@/types/app'
|
||||
import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types'
|
||||
import type { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
||||
import type { NodeTracing } from '@/types/workflow'
|
||||
import type { FileResponse, NodeTracing } from '@/types/workflow'
|
||||
import type { Collection, Tool } from '@/app/components/tools/types'
|
||||
import type { ChatVarType } from '@/app/components/workflow/panel/chat-variable-panel/type'
|
||||
|
||||
@ -326,6 +326,7 @@ export type WorkflowRunningData = {
|
||||
steps?: number
|
||||
showSteps?: boolean
|
||||
total_steps?: number
|
||||
files?: FileResponse[]
|
||||
}
|
||||
tracing?: NodeTracing[]
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ export type WorkflowFinishedResponse = {
|
||||
email: string
|
||||
}
|
||||
finished_at: number
|
||||
files?: FileResponse[]
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user