diff --git a/app/components/welcome/index.tsx b/app/components/welcome/index.tsx index b01e131..9b18105 100644 --- a/app/components/welcome/index.tsx +++ b/app/components/welcome/index.tsx @@ -37,6 +37,7 @@ const Welcome: FC = ({ savedInputs, onInputsChange, }) => { + console.log(promptConfig) const { t } = useTranslation() const hasVar = promptConfig.prompt_variables.length > 0 const [isFold, setIsFold] = useState(true) @@ -136,14 +137,30 @@ const Welcome: FC = ({ { item.type === 'file' && ( { + setInputs({ ...inputs, [item.key]: files[0] }) + }} + value={inputs?.[item.key] || []} + /> + ) + } + { + item.type === 'file-list' && ( + { setInputs({ ...inputs, [item.key]: files }) }} diff --git a/types/app.ts b/types/app.ts index 3d62c4f..06b287f 100644 --- a/types/app.ts +++ b/types/app.ts @@ -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 = { diff --git a/utils/prompt.ts b/utils/prompt.ts index e099422..be0a754 100644 --- a/utils/prompt.ts +++ b/utils/prompt.ts @@ -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,