chore: can use setting config

This commit is contained in:
Joel
2025-04-15 18:18:46 +08:00
parent 4ae03c2101
commit beda954867
3 changed files with 36 additions and 5 deletions

View File

@ -37,6 +37,7 @@ const Welcome: FC<IWelcomeProps> = ({
savedInputs,
onInputsChange,
}) => {
console.log(promptConfig)
const { t } = useTranslation()
const hasVar = promptConfig.prompt_variables.length > 0
const [isFold, setIsFold] = useState<boolean>(true)
@ -136,14 +137,30 @@ const Welcome: FC<IWelcomeProps> = ({
{
item.type === 'file' && (
<FileUploaderInAttachmentWrapper
className='w-full'
fileConfig={{
allowed_file_types: ['image', 'video', 'audio', 'document'],
allowed_file_extensions: ['jpg', 'jpeg', 'png', 'gif'],
allowed_file_upload_methods: ['local_file', 'remote_url'],
allowed_file_types: item.allowed_file_types,
allowed_file_extensions: item.allowed_file_extensions,
allowed_file_upload_methods: item.allowed_file_upload_methods!,
number_limits: 1,
fileUploadConfig: {} as any,
}}
onChange={(files) => {
setInputs({ ...inputs, [item.key]: files[0] })
}}
value={inputs?.[item.key] || []}
/>
)
}
{
item.type === 'file-list' && (
<FileUploaderInAttachmentWrapper
fileConfig={{
allowed_file_types: item.allowed_file_types,
allowed_file_extensions: item.allowed_file_extensions,
allowed_file_upload_methods: item.allowed_file_upload_methods!,
number_limits: item.max_length,
fileUploadConfig: {} as any,
}}
onChange={(files) => {
setInputs({ ...inputs, [item.key]: files })
}}

View File

@ -10,6 +10,9 @@ export type PromptVariable = {
options?: string[]
max_length?: number
required: boolean
allowed_file_extensions?: string[]
allowed_file_types?: string[]
allowed_file_upload_methods?: TransferMethod[]
}
export type PromptConfig = {

View File

@ -21,7 +21,7 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
return [type === 'text-input' ? 'string' : type, item[type]]
})()
if (type === 'string' || type === 'paragraph' || type === 'file' || type === 'file-list') {
if (type === 'string' || type === 'paragraph') {
promptVariables.push({
key: content.variable,
name: content.label,
@ -40,6 +40,17 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
options: [],
})
}
else if (type === 'file' || type === 'file-list') {
promptVariables.push({
...content,
key: content.variable,
name: content.label,
required: content.required,
type,
max_length: content.max_length,
options: [],
})
}
else {
promptVariables.push({
key: content.variable,