Feat: use file size limit from api (#9739)
This commit is contained in:
parent
2346b0ab99
commit
5d1424f67c
19 changed files with 205 additions and 28 deletions
|
|
@ -1,6 +1,5 @@
|
|||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import produce, { setAutoFreeze } from 'immer'
|
||||
|
|
@ -39,7 +38,6 @@ import { promptVariablesToUserInputsForm } from '@/utils/model-config'
|
|||
import TextGeneration from '@/app/components/app/text-generate/item'
|
||||
import { IS_CE_EDITION } from '@/config'
|
||||
import type { Inputs } from '@/models/debug'
|
||||
import { fetchFileUploadConfig } from '@/service/common'
|
||||
import { useDefaultModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import { ModelFeatureEnum, ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||
import type { ModelParameterModalProps } from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
|
||||
|
|
@ -94,7 +92,6 @@ const Debug: FC<IDebug> = ({
|
|||
} = useContext(ConfigContext)
|
||||
const { eventEmitter } = useEventEmitterContextContext()
|
||||
const { data: text2speechDefaultModel } = useDefaultModel(ModelTypeEnum.textEmbedding)
|
||||
const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig)
|
||||
useEffect(() => {
|
||||
setAutoFreeze(false)
|
||||
return () => {
|
||||
|
|
@ -452,7 +449,7 @@ const Debug: FC<IDebug> = ({
|
|||
visionConfig={{
|
||||
...features.file! as VisionSettings,
|
||||
transfer_methods: features.file!.allowed_file_upload_methods || [],
|
||||
image_file_size_limit: fileUploadConfigResponse?.image_file_size_limit,
|
||||
image_file_size_limit: features.file?.fileUploadConfig?.image_file_size_limit,
|
||||
}}
|
||||
onVisionFilesChange={setCompletionFiles}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useContext } from 'use-context-selector'
|
||||
import { usePathname } from 'next/navigation'
|
||||
|
|
@ -69,6 +70,7 @@ import type { Features as FeaturesData, FileUpload } from '@/app/components/base
|
|||
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
||||
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
||||
import NewFeaturePanel from '@/app/components/base/features/new-feature-panel'
|
||||
import { fetchFileUploadConfig } from '@/service/common'
|
||||
|
||||
type PublishConfig = {
|
||||
modelConfig: ModelConfig
|
||||
|
|
@ -84,6 +86,8 @@ const Configuration: FC = () => {
|
|||
showAppConfigureFeaturesModal: state.showAppConfigureFeaturesModal,
|
||||
setShowAppConfigureFeaturesModal: state.setShowAppConfigureFeaturesModal,
|
||||
})))
|
||||
const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig)
|
||||
|
||||
const latestPublishedAt = useMemo(() => appDetail?.model_config.updated_at, [appDetail])
|
||||
const [formattingChanged, setFormattingChanged] = useState(false)
|
||||
const { setShowAccountSettingModal } = useModalContext()
|
||||
|
|
@ -462,12 +466,13 @@ const Configuration: FC = () => {
|
|||
allowed_file_extensions: modelConfig.file_upload?.allowed_file_extensions || FILE_EXTS[SupportUploadFileTypes.image].map(ext => `.${ext}`),
|
||||
allowed_file_upload_methods: modelConfig.file_upload?.allowed_file_upload_methods || modelConfig.file_upload?.image?.transfer_methods || ['local_file', 'remote_url'],
|
||||
number_limits: modelConfig.file_upload?.number_limits || modelConfig.file_upload?.image?.number_limits || 3,
|
||||
fileUploadConfig: fileUploadConfigResponse,
|
||||
} as FileUpload,
|
||||
suggested: modelConfig.suggested_questions_after_answer || { enabled: false },
|
||||
citation: modelConfig.retriever_resource || { enabled: false },
|
||||
annotationReply: modelConfig.annotation_reply || { enabled: false },
|
||||
}
|
||||
}, [modelConfig])
|
||||
}, [fileUploadConfigResponse, modelConfig])
|
||||
const handleFeaturesChange = useCallback((flag: any) => {
|
||||
setShowAppConfigureFeaturesModal(true)
|
||||
if (flag)
|
||||
|
|
@ -684,6 +689,9 @@ const Configuration: FC = () => {
|
|||
},
|
||||
}))
|
||||
|
||||
const fileUpload = { ...features?.file }
|
||||
delete fileUpload?.fileUploadConfig
|
||||
|
||||
// new model config data struct
|
||||
const data: BackendModelConfig = {
|
||||
// Simple Mode prompt
|
||||
|
|
@ -700,7 +708,7 @@ const Configuration: FC = () => {
|
|||
sensitive_word_avoidance: features?.moderation as any,
|
||||
speech_to_text: features?.speech2text as any,
|
||||
text_to_speech: features?.text2speech as any,
|
||||
file_upload: features?.file as any,
|
||||
file_upload: fileUpload as any,
|
||||
suggested_questions_after_answer: features?.suggested as any,
|
||||
retriever_resource: features?.citation as any,
|
||||
agent_mode: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue