mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 21:45:59 +08:00
file var in form
This commit is contained in:
parent
a10b0db102
commit
96d2582d89
@ -153,12 +153,12 @@ const ConfigModal: FC<IConfigModalProps> = ({
|
|||||||
}
|
}
|
||||||
else if ([InputVarType.singleFile, InputVarType.multiFiles].includes(type)) {
|
else if ([InputVarType.singleFile, InputVarType.multiFiles].includes(type)) {
|
||||||
if (tempPayload.allowed_file_types?.length === 0) {
|
if (tempPayload.allowed_file_types?.length === 0) {
|
||||||
const errorMessages = t('workflow.errorMsg.fieldRequired', { field: t('appDebug.variableConig.file.supportFileTypes') })
|
const errorMessages = t('workflow.errorMsg.fieldRequired', { field: t('appDebug.variableConfig.file.supportFileTypes') })
|
||||||
Toast.notify({ type: 'error', message: errorMessages })
|
Toast.notify({ type: 'error', message: errorMessages })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (tempPayload.allowed_file_types?.includes(SupportUploadFileTypes.custom) && !tempPayload.allowed_file_extensions?.length) {
|
if (tempPayload.allowed_file_types?.includes(SupportUploadFileTypes.custom) && !tempPayload.allowed_file_extensions?.length) {
|
||||||
const errorMessages = t('workflow.errorMsg.fieldRequired', { field: t('appDebug.variableConig.file.custom.name') })
|
const errorMessages = t('workflow.errorMsg.fieldRequired', { field: t('appDebug.variableConfig.file.custom.name') })
|
||||||
Toast.notify({ type: 'error', message: errorMessages })
|
Toast.notify({ type: 'error', message: errorMessages })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
|
|||||||
<div className='mb-8'>
|
<div className='mb-8'>
|
||||||
<div className='space-y-2'>
|
<div className='space-y-2'>
|
||||||
|
|
||||||
<Field title={t('appDebug.variableConig.fieldType')}>
|
<Field title={t('appDebug.variableConfig.fieldType')}>
|
||||||
<div className='grid grid-cols-3 gap-2'>
|
<div className='grid grid-cols-3 gap-2'>
|
||||||
<SelectTypeItem type={InputVarType.textInput} selected={type === InputVarType.textInput} onClick={handleTypeChange(InputVarType.textInput)} />
|
<SelectTypeItem type={InputVarType.textInput} selected={type === InputVarType.textInput} onClick={handleTypeChange(InputVarType.textInput)} />
|
||||||
<SelectTypeItem type={InputVarType.paragraph} selected={type === InputVarType.paragraph} onClick={handleTypeChange(InputVarType.paragraph)} />
|
<SelectTypeItem type={InputVarType.paragraph} selected={type === InputVarType.paragraph} onClick={handleTypeChange(InputVarType.paragraph)} />
|
||||||
@ -191,7 +191,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field title={t('appDebug.variableConig.varName')}>
|
<Field title={t('appDebug.variableConfig.varName')}>
|
||||||
<Input
|
<Input
|
||||||
value={variable}
|
value={variable}
|
||||||
onChange={e => handlePayloadChange('variable')(e.target.value)}
|
onChange={e => handlePayloadChange('variable')(e.target.value)}
|
||||||
@ -199,7 +199,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
|
|||||||
placeholder={t('appDebug.variableConfig.inputPlaceholder')!}
|
placeholder={t('appDebug.variableConfig.inputPlaceholder')!}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
<Field title={t('appDebug.variableConig.labelName')}>
|
<Field title={t('appDebug.variableConfig.labelName')}>
|
||||||
<Input
|
<Input
|
||||||
value={label as string}
|
value={label as string}
|
||||||
onChange={e => handlePayloadChange('label')(e.target.value)}
|
onChange={e => handlePayloadChange('label')(e.target.value)}
|
||||||
@ -229,7 +229,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
|
|||||||
|
|
||||||
<div className='!mt-5 flex items-center h-6 space-x-2'>
|
<div className='!mt-5 flex items-center h-6 space-x-2'>
|
||||||
<Checkbox checked={tempPayload.required} onCheck={() => handlePayloadChange('required')(!tempPayload.required)} />
|
<Checkbox checked={tempPayload.required} onCheck={() => handlePayloadChange('required')(!tempPayload.required)} />
|
||||||
<span className='text-text-secondary system-sm-semibold'>{t('appDebug.variableConig.required')}</span>
|
<span className='text-text-secondary system-sm-semibold'>{t('appDebug.variableConfig.required')}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,7 +22,7 @@ const SelectTypeItem: FC<ISelectTypeItemProps> = ({
|
|||||||
onClick,
|
onClick,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const typeName = t(`appDebug.variableConig.${i18nFileTypeMap[type] || type}`)
|
const typeName = t(`appDebug.variableConfig.${i18nFileTypeMap[type] || type}`)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -38,7 +38,7 @@ const Operation = forwardRef<HTMLDivElement, OperationProps>(({
|
|||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
<div className='flex items-center space-x-1'>
|
<div className='flex items-center space-x-1'>
|
||||||
<FileUploaderInChatInput />
|
{visionConfig?.enabled && <FileUploaderInChatInput />}
|
||||||
{
|
{
|
||||||
speechToTextConfig?.enabled && (
|
speechToTextConfig?.enabled && (
|
||||||
<ActionButton
|
<ActionButton
|
||||||
|
@ -140,7 +140,7 @@ const OpeningSettingModal = ({
|
|||||||
onClick={() => { setTempSuggestedQuestions([...tempSuggestedQuestions, '']) }}
|
onClick={() => { setTempSuggestedQuestions([...tempSuggestedQuestions, '']) }}
|
||||||
className='mt-1 flex items-center h-9 px-3 gap-2 rounded-lg cursor-pointer text-gray-400 bg-gray-100 hover:bg-gray-200'>
|
className='mt-1 flex items-center h-9 px-3 gap-2 rounded-lg cursor-pointer text-gray-400 bg-gray-100 hover:bg-gray-200'>
|
||||||
<RiAddLine className='w-4 h-4' />
|
<RiAddLine className='w-4 h-4' />
|
||||||
<div className='text-gray-500 text-[13px]'>{t('appDebug.variableConig.addOption')}</div>
|
<div className='text-gray-500 text-[13px]'>{t('appDebug.variableConfig.addOption')}</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -75,8 +75,8 @@ export const useNodesSyncDraft = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
features: {
|
features: {
|
||||||
opening_statement: features.opening?.opening_statement || '',
|
opening_statement: features.opening?.enabled ? (features.opening?.opening_statement || '') : '',
|
||||||
suggested_questions: features.opening?.suggested_questions || [],
|
suggested_questions: features.opening?.enabled ? (features.opening?.suggested_questions || []) : [],
|
||||||
suggested_questions_after_answer: features.suggested,
|
suggested_questions_after_answer: features.suggested,
|
||||||
text_to_speech: features.text2speech,
|
text_to_speech: features.text2speech,
|
||||||
speech_to_text: features.speech2text,
|
speech_to_text: features.speech2text,
|
||||||
|
@ -15,6 +15,7 @@ import Select from '@/app/components/base/select'
|
|||||||
import Input from '@/app/components/base/input'
|
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 { Resolution } from '@/types/app'
|
import { Resolution } 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'
|
||||||
@ -156,7 +157,10 @@ const FormItem: FC<Props> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
{/* #TODO# file type new form */}
|
{/* #TODO# file upload */}
|
||||||
|
{(type === InputVarType.singleFile || type === InputVarType.multiFiles) && (
|
||||||
|
<FileUploaderInAttachmentWrapper onChange={() => {}} />
|
||||||
|
)}
|
||||||
{
|
{
|
||||||
type === InputVarType.files && (
|
type === InputVarType.files && (
|
||||||
<TextGenerationImageUploader
|
<TextGenerationImageUploader
|
||||||
|
@ -46,14 +46,14 @@ const FileTypeItem: FC<Props> = ({
|
|||||||
<div>
|
<div>
|
||||||
<div className='flex items-center p-3 pb-2 border-b border-divider-subtle'>
|
<div className='flex items-center p-3 pb-2 border-b border-divider-subtle'>
|
||||||
<span className='shrink-0 w-4 h-4 bg-[#00B2EA]'></span>
|
<span className='shrink-0 w-4 h-4 bg-[#00B2EA]'></span>
|
||||||
<div className='mx-2 grow text-text-primary system-sm-medium'>{t(`appDebug.variableConig.file.${type}.name`)}</div>
|
<div className='mx-2 grow text-text-primary system-sm-medium'>{t(`appDebug.variableConfig.file.${type}.name`)}</div>
|
||||||
<Checkbox className='shrink-0' checked={selected} />
|
<Checkbox className='shrink-0' checked={selected} />
|
||||||
</div>
|
</div>
|
||||||
<div className='p-3' onClick={e => e.stopPropagation()}>
|
<div className='p-3' onClick={e => e.stopPropagation()}>
|
||||||
<TagInput
|
<TagInput
|
||||||
items={customFileTypes}
|
items={customFileTypes}
|
||||||
onChange={onCustomFileTypesChange}
|
onChange={onCustomFileTypesChange}
|
||||||
placeholder={t('appDebug.variableConig.file.custom.createPlaceholder')!}
|
placeholder={t('appDebug.variableConfig.file.custom.createPlaceholder')!}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -63,8 +63,8 @@ const FileTypeItem: FC<Props> = ({
|
|||||||
{/* TODO: Wait File type icon */}
|
{/* TODO: Wait File type icon */}
|
||||||
<span className='shrink-0 w-4 h-4 bg-[#00B2EA]'></span>
|
<span className='shrink-0 w-4 h-4 bg-[#00B2EA]'></span>
|
||||||
<div className='mx-2 grow'>
|
<div className='mx-2 grow'>
|
||||||
<div className='text-text-primary system-sm-medium'>{t(`appDebug.variableConig.file.${type}.name`)}</div>
|
<div className='text-text-primary system-sm-medium'>{t(`appDebug.variableConfig.file.${type}.name`)}</div>
|
||||||
<div className='mt-1 text-text-tertiary system-2xs-regular-uppercase'>{type !== SupportUploadFileTypes.custom ? FILE_EXTS[type].join(', ') : t('appDebug.variableConig.file.custom.description')}</div>
|
<div className='mt-1 text-text-tertiary system-2xs-regular-uppercase'>{type !== SupportUploadFileTypes.custom ? FILE_EXTS[type].join(', ') : t('appDebug.variableConfig.file.custom.description')}</div>
|
||||||
</div>
|
</div>
|
||||||
<Checkbox className='shrink-0' checked={selected} />
|
<Checkbox className='shrink-0' checked={selected} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -87,7 +87,7 @@ const FileUploadSetting: FC<Props> = ({
|
|||||||
<div>
|
<div>
|
||||||
{!inFeaturePanel && (
|
{!inFeaturePanel && (
|
||||||
<Field
|
<Field
|
||||||
title={t('appDebug.variableConig.file.supportFileTypes')}
|
title={t('appDebug.variableConfig.file.supportFileTypes')}
|
||||||
>
|
>
|
||||||
<div className='space-y-1'>
|
<div className='space-y-1'>
|
||||||
{
|
{
|
||||||
@ -135,10 +135,10 @@ const FileUploadSetting: FC<Props> = ({
|
|||||||
{isMultiple && (
|
{isMultiple && (
|
||||||
<Field
|
<Field
|
||||||
className='mt-4'
|
className='mt-4'
|
||||||
title={t('appDebug.variableConig.maxNumberOfUploads')!}
|
title={t('appDebug.variableConfig.maxNumberOfUploads')!}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<div className='mb-1.5 text-text-tertiary body-xs-regular'>{t('appDebug.variableConig.maxNumberTip')}</div>
|
<div className='mb-1.5 text-text-tertiary body-xs-regular'>{t('appDebug.variableConfig.maxNumberTip')}</div>
|
||||||
<InputNumberWithSlider
|
<InputNumberWithSlider
|
||||||
value={max_length}
|
value={max_length}
|
||||||
min={1}
|
min={1}
|
||||||
@ -150,7 +150,7 @@ const FileUploadSetting: FC<Props> = ({
|
|||||||
)}
|
)}
|
||||||
{inFeaturePanel && (
|
{inFeaturePanel && (
|
||||||
<Field
|
<Field
|
||||||
title={t('appDebug.variableConig.file.supportFileTypes')}
|
title={t('appDebug.variableConfig.file.supportFileTypes')}
|
||||||
className='mt-4'
|
className='mt-4'
|
||||||
>
|
>
|
||||||
<div className='space-y-1'>
|
<div className='space-y-1'>
|
||||||
|
@ -42,8 +42,8 @@ const ChatWrapper = forwardRef<ChatWrapperRefType, ChatWrapperProps>(({ showConv
|
|||||||
const features = useFeatures(s => s.features)
|
const features = useFeatures(s => s.features)
|
||||||
const config = useMemo(() => {
|
const config = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
opening_statement: features.opening?.opening_statement || '',
|
opening_statement: features.opening?.enabled ? (features.opening?.opening_statement || '') : '',
|
||||||
suggested_questions: features.opening?.suggested_questions || [],
|
suggested_questions: features.opening?.enabled ? (features.opening?.suggested_questions || []) : [],
|
||||||
suggested_questions_after_answer: features.suggested,
|
suggested_questions_after_answer: features.suggested,
|
||||||
text_to_speech: features.text2speech,
|
text_to_speech: features.text2speech,
|
||||||
speech_to_text: features.speech2text,
|
speech_to_text: features.speech2text,
|
||||||
@ -51,7 +51,7 @@ const ChatWrapper = forwardRef<ChatWrapperRefType, ChatWrapperProps>(({ showConv
|
|||||||
sensitive_word_avoidance: features.moderation,
|
sensitive_word_avoidance: features.moderation,
|
||||||
file_upload: features.file,
|
file_upload: features.file,
|
||||||
}
|
}
|
||||||
}, [features])
|
}, [features.opening, features.suggested, features.text2speech, features.speech2text, features.citation, features.moderation, features.file])
|
||||||
const setShowFeaturesPanel = useStore(s => s.setShowFeaturesPanel)
|
const setShowFeaturesPanel = useStore(s => s.setShowFeaturesPanel)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -104,7 +104,8 @@ const ChatWrapper = forwardRef<ChatWrapperRefType, ChatWrapperProps>(({ showConv
|
|||||||
chatContainerClassName='px-3'
|
chatContainerClassName='px-3'
|
||||||
chatContainerInnerClassName='pt-6 w-full max-w-full mx-auto'
|
chatContainerInnerClassName='pt-6 w-full max-w-full mx-auto'
|
||||||
chatFooterClassName='px-4 rounded-bl-2xl'
|
chatFooterClassName='px-4 rounded-bl-2xl'
|
||||||
chatFooterInnerClassName='pb-2'
|
chatFooterInnerClassName='pb-0'
|
||||||
|
showFileUpload
|
||||||
showFeatureBar
|
showFeatureBar
|
||||||
onFeatureBarClick={setShowFeaturesPanel}
|
onFeatureBarClick={setShowFeaturesPanel}
|
||||||
onSend={doSend}
|
onSend={doSend}
|
||||||
|
@ -85,6 +85,7 @@ const DebugAndPreview = () => {
|
|||||||
<RiEqualizer2Line className='w-4 h-4' />
|
<RiEqualizer2Line className='w-4 h-4' />
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
{expanded && <div className='absolute z-10 bottom-[-17px] right-[5px] w-3 h-3 bg-components-panel-on-panel-item-bg border-l-[0.5px] border-t-[0.5px] border-components-panel-border-subtle rotate-45'/>}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className='mx-3 w-[1px] h-3.5 bg-gray-200'></div>
|
<div className='mx-3 w-[1px] h-3.5 bg-gray-200'></div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user