mirror of
https://github.com/langgenius/webapp-conversation.git
synced 2025-12-08 17:32:27 +08:00
chore: can use setting config
This commit is contained in:
@ -37,6 +37,7 @@ const Welcome: FC<IWelcomeProps> = ({
|
|||||||
savedInputs,
|
savedInputs,
|
||||||
onInputsChange,
|
onInputsChange,
|
||||||
}) => {
|
}) => {
|
||||||
|
console.log(promptConfig)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const hasVar = promptConfig.prompt_variables.length > 0
|
const hasVar = promptConfig.prompt_variables.length > 0
|
||||||
const [isFold, setIsFold] = useState<boolean>(true)
|
const [isFold, setIsFold] = useState<boolean>(true)
|
||||||
@ -136,14 +137,30 @@ const Welcome: FC<IWelcomeProps> = ({
|
|||||||
{
|
{
|
||||||
item.type === 'file' && (
|
item.type === 'file' && (
|
||||||
<FileUploaderInAttachmentWrapper
|
<FileUploaderInAttachmentWrapper
|
||||||
className='w-full'
|
|
||||||
fileConfig={{
|
fileConfig={{
|
||||||
allowed_file_types: ['image', 'video', 'audio', 'document'],
|
allowed_file_types: item.allowed_file_types,
|
||||||
allowed_file_extensions: ['jpg', 'jpeg', 'png', 'gif'],
|
allowed_file_extensions: item.allowed_file_extensions,
|
||||||
allowed_file_upload_methods: ['local_file', 'remote_url'],
|
allowed_file_upload_methods: item.allowed_file_upload_methods!,
|
||||||
number_limits: 1,
|
number_limits: 1,
|
||||||
fileUploadConfig: {} as any,
|
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) => {
|
onChange={(files) => {
|
||||||
setInputs({ ...inputs, [item.key]: files })
|
setInputs({ ...inputs, [item.key]: files })
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -10,6 +10,9 @@ export type PromptVariable = {
|
|||||||
options?: string[]
|
options?: string[]
|
||||||
max_length?: number
|
max_length?: number
|
||||||
required: boolean
|
required: boolean
|
||||||
|
allowed_file_extensions?: string[]
|
||||||
|
allowed_file_types?: string[]
|
||||||
|
allowed_file_upload_methods?: TransferMethod[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PromptConfig = {
|
export type PromptConfig = {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
|||||||
return [type === 'text-input' ? 'string' : type, item[type]]
|
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({
|
promptVariables.push({
|
||||||
key: content.variable,
|
key: content.variable,
|
||||||
name: content.label,
|
name: content.label,
|
||||||
@ -40,6 +40,17 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
|||||||
options: [],
|
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 {
|
else {
|
||||||
promptVariables.push({
|
promptVariables.push({
|
||||||
key: content.variable,
|
key: content.variable,
|
||||||
|
|||||||
Reference in New Issue
Block a user