fix step run of file type

This commit is contained in:
JzoNg 2024-09-24 16:24:46 +08:00
parent 8b26ae6532
commit dc5010d833
6 changed files with 45 additions and 20 deletions

View File

@ -61,7 +61,7 @@ const NewFeaturePanel = ({
</div> </div>
{/* list */} {/* list */}
<div className='grow overflow-y-auto px-4 pb-4'> <div className='grow overflow-y-auto px-4 pb-4'>
{!isChatMode && ( {!isChatMode && !inWorkflow && (
<MoreLikeThis disabled={disabled} onChange={onChange} /> <MoreLikeThis disabled={disabled} onChange={onChange} />
)} )}
{isChatMode && ( {isChatMode && (
@ -72,20 +72,20 @@ const NewFeaturePanel = ({
onAutoAddPromptVariable={onAutoAddPromptVariable} onAutoAddPromptVariable={onAutoAddPromptVariable}
/> />
)} )}
<Moderation disabled={disabled} onChange={onChange} />
{isChatMode && speech2textDefaultModel && (
<SpeechToText disabled={disabled} onChange={onChange} />
)}
{text2speechDefaultModel && (
<TextToSpeech disabled={disabled} onChange={onChange} />
)}
{showFileUpload && <FileUpload disabled={disabled} onChange={onChange} />}
{isChatMode && ( {isChatMode && (
<FollowUp disabled={disabled} onChange={onChange} /> <FollowUp disabled={disabled} onChange={onChange} />
)} )}
{text2speechDefaultModel && (isChatMode || !inWorkflow) && (
<TextToSpeech disabled={disabled} onChange={onChange} />
)}
{isChatMode && speech2textDefaultModel && (
<SpeechToText disabled={disabled} onChange={onChange} />
)}
{showFileUpload && isChatMode && <FileUpload disabled={disabled} onChange={onChange} />}
{isChatMode && ( {isChatMode && (
<Citation disabled={disabled} onChange={onChange} /> <Citation disabled={disabled} onChange={onChange} />
)} )}
{(isChatMode || !inWorkflow) && <Moderation disabled={disabled} onChange={onChange} />}
{!inWorkflow && isChatMode && ( {!inWorkflow && isChatMode && (
<AnnotationReply disabled={disabled} onChange={onChange} /> <AnnotationReply disabled={disabled} onChange={onChange} />
)} )}

View File

@ -14,6 +14,7 @@ import TextGenerationImageUploader from '@/app/components/base/image-uploader/te
import type { VisionFile, VisionSettings } from '@/types/app' import type { VisionFile, VisionSettings } from '@/types/app'
import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader' import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader'
import { getProcessedFiles } from '@/app/components/base/file-uploader/utils' import { getProcessedFiles } from '@/app/components/base/file-uploader/utils'
// import { InputVarType } from '@/app/components/workflow/types'
export type IRunOnceProps = { export type IRunOnceProps = {
siteInfo: SiteInfo siteInfo: SiteInfo

View File

@ -4,6 +4,7 @@ import {
useCallback, useCallback,
useMemo, useMemo,
} from 'react' } from 'react'
import { RiApps2AddLine } from '@remixicon/react'
import { useNodes } from 'reactflow' import { useNodes } from 'reactflow'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useContext } from 'use-context-selector' import { useContext } from 'use-context-selector'
@ -46,7 +47,7 @@ const Header: FC = () => {
const appSidebarExpand = useAppStore(s => s.appSidebarExpand) const appSidebarExpand = useAppStore(s => s.appSidebarExpand)
const appID = appDetail?.id const appID = appDetail?.id
const isChatMode = useIsChatMode() const isChatMode = useIsChatMode()
const { nodesReadOnly } = useNodesReadOnly() const { nodesReadOnly, getNodesReadOnly } = useNodesReadOnly()
const publishedAt = useStore(s => s.publishedAt) const publishedAt = useStore(s => s.publishedAt)
const draftUpdatedAt = useStore(s => s.draftUpdatedAt) const draftUpdatedAt = useStore(s => s.draftUpdatedAt)
const toolPublished = useStore(s => s.toolPublished) const toolPublished = useStore(s => s.toolPublished)
@ -85,6 +86,17 @@ const Header: FC = () => {
viewHistory, viewHistory,
} = useWorkflowMode() } = useWorkflowMode()
const handleShowFeatures = useCallback(() => {
const {
showFeaturesPanel,
isRestoring,
setShowFeaturesPanel,
} = workflowStore.getState()
if (getNodesReadOnly() && !isRestoring)
return
setShowFeaturesPanel(!showFeaturesPanel)
}, [workflowStore, getNodesReadOnly])
const handleCancelRestore = useCallback(() => { const handleCancelRestore = useCallback(() => {
handleLoadBackupDraft() handleLoadBackupDraft()
workflowStore.setState({ isRestoring: false }) workflowStore.setState({ isRestoring: false })
@ -161,6 +173,10 @@ const Header: FC = () => {
<EnvButton disabled={nodesReadOnly} /> <EnvButton disabled={nodesReadOnly} />
<div className='w-[1px] h-3.5 bg-gray-200'></div> <div className='w-[1px] h-3.5 bg-gray-200'></div>
<RunAndHistory /> <RunAndHistory />
<Button className='text-components-button-secondary-text' onClick={handleShowFeatures}>
<RiApps2AddLine className='w-4 h-4 mr-1 text-components-button-secondary-text' />
{t('workflow.common.features')}
</Button>
<AppPublisher <AppPublisher
{...{ {...{
publishedAt, publishedAt,
@ -197,6 +213,11 @@ const Header: FC = () => {
{ {
restoring && ( restoring && (
<div className='flex items-center'> <div className='flex items-center'>
<Button className='text-components-button-secondary-text' onClick={handleShowFeatures}>
<RiApps2AddLine className='w-4 h-4 mr-1 text-components-button-secondary-text' />
{t('workflow.common.features')}
</Button>
<div className='mx-2 w-[1px] h-3.5 bg-gray-200'></div>
<Button <Button
className='mr-2' className='mr-2'
onClick={handleCancelRestore} onClick={handleCancelRestore}

View File

@ -7,7 +7,7 @@ import {
RiDeleteBinLine, RiDeleteBinLine,
} from '@remixicon/react' } from '@remixicon/react'
import type { InputVar } from '../../../../types' import type { InputVar } from '../../../../types'
import { BlockEnum, InputVarType } from '../../../../types' import { BlockEnum, InputVarType, SupportUploadFileTypes } from '../../../../types'
import CodeEditor from '../editor/code-editor' import CodeEditor from '../editor/code-editor'
import { CodeLanguage } from '../../../code/types' import { CodeLanguage } from '../../../code/types'
import TextEditor from '../editor/text-editor' import TextEditor from '../editor/text-editor'
@ -16,7 +16,7 @@ import Input from '@/app/components/base/input'
import Textarea from '@/app/components/base/textarea' import Textarea from '@/app/components/base/textarea'
import TextGenerationImageUploader from '@/app/components/base/image-uploader/text-generation-image-uploader' import TextGenerationImageUploader from '@/app/components/base/image-uploader/text-generation-image-uploader'
import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader' import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader'
import { Resolution } from '@/types/app' import { Resolution, TransferMethod } from '@/types/app'
import { useFeatures } from '@/app/components/base/features/hooks' import { useFeatures } from '@/app/components/base/features/hooks'
import { VarBlockIcon } from '@/app/components/workflow/block-icon' import { VarBlockIcon } from '@/app/components/workflow/block-icon'
import { Line3 } from '@/app/components/base/icons/src/public/common' import { Line3 } from '@/app/components/base/icons/src/public/common'
@ -31,6 +31,7 @@ type Props = {
onChange: (value: any) => void onChange: (value: any) => void
className?: string className?: string
autoFocus?: boolean autoFocus?: boolean
inStepRun?: boolean
} }
const FormItem: FC<Props> = ({ const FormItem: FC<Props> = ({
@ -39,6 +40,7 @@ const FormItem: FC<Props> = ({
onChange, onChange,
className, className,
autoFocus, autoFocus,
inStepRun = false,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const { type } = payload const { type } = payload
@ -164,9 +166,9 @@ const FormItem: FC<Props> = ({
onChange(getProcessedFiles(files)[0]) onChange(getProcessedFiles(files)[0])
}} }}
fileConfig={{ fileConfig={{
allowed_file_types: payload.allowed_file_types, allowed_file_types: inStepRun ? [SupportUploadFileTypes.custom] : payload.allowed_file_types,
allowed_file_extensions: payload.allowed_file_extensions, allowed_file_extensions: inStepRun ? [] : payload.allowed_file_extensions,
allowed_file_upload_methods: payload.allowed_file_upload_methods, allowed_file_upload_methods: inStepRun ? [TransferMethod.local_file, TransferMethod.remote_url] : payload.allowed_file_upload_methods,
number_limits: 1, number_limits: 1,
}} }}
/> />
@ -175,10 +177,10 @@ const FormItem: FC<Props> = ({
<FileUploaderInAttachmentWrapper <FileUploaderInAttachmentWrapper
onChange={files => onChange(getProcessedFiles(files))} onChange={files => onChange(getProcessedFiles(files))}
fileConfig={{ fileConfig={{
allowed_file_types: payload.allowed_file_types, allowed_file_types: inStepRun ? [SupportUploadFileTypes.custom] : payload.allowed_file_types,
allowed_file_extensions: payload.allowed_file_extensions, allowed_file_extensions: inStepRun ? [] : payload.allowed_file_extensions,
allowed_file_upload_methods: payload.allowed_file_upload_methods, allowed_file_upload_methods: inStepRun ? [TransferMethod.local_file, TransferMethod.remote_url] : payload.allowed_file_upload_methods,
number_limits: payload.max_length, number_limits: inStepRun ? 5 : payload.max_length,
}} }}
/> />
)} )}

View File

@ -80,6 +80,7 @@ const Form: FC<Props> = ({
{inputs.map((input, index) => { {inputs.map((input, index) => {
return ( return (
<FormItem <FormItem
inStepRun
key={index} key={index}
payload={input} payload={input}
value={values[input.variable]} value={values[input.variable]}

View File

@ -83,7 +83,7 @@ const varTypeToInputVarType = (type: VarType, {
if (type === VarType.file) if (type === VarType.file)
return InputVarType.singleFile return InputVarType.singleFile
if (type === VarType.arrayFile) if (type === VarType.arrayFile)
return InputVarType.files return InputVarType.multiFiles
return InputVarType.textInput return InputVarType.textInput
} }