mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
text-generation support file type
This commit is contained in:
parent
195ac19774
commit
f8d26e46ac
|
@ -392,6 +392,7 @@ const TextGeneration: FC<IMainProps> = ({
|
||||||
image_file_size_limit: appParams?.system_parameters?.image_file_size_limit,
|
image_file_size_limit: appParams?.system_parameters?.image_file_size_limit,
|
||||||
})
|
})
|
||||||
const prompt_variables = userInputsFormToPromptVariables(user_input_form)
|
const prompt_variables = userInputsFormToPromptVariables(user_input_form)
|
||||||
|
console.log(prompt_variables)
|
||||||
setPromptConfig({
|
setPromptConfig({
|
||||||
prompt_template: '', // placeholder for future
|
prompt_template: '', // placeholder for future
|
||||||
prompt_variables,
|
prompt_variables,
|
||||||
|
|
|
@ -94,6 +94,18 @@ const RunOnce: FC<IRunOnceProps> = ({
|
||||||
onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }}
|
onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{item.type === 'file' && (
|
||||||
|
<FileUploaderInAttachmentWrapper
|
||||||
|
onChange={(files) => { onInputsChange({ ...inputs, [item.key]: getProcessedFiles(files)[0] }) }}
|
||||||
|
fileConfig={item.config as any}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{item.type === 'file-list' && (
|
||||||
|
<FileUploaderInAttachmentWrapper
|
||||||
|
onChange={(files) => { onInputsChange({ ...inputs, [item.key]: getProcessedFiles(files) }) }}
|
||||||
|
fileConfig={item.config as any}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
@ -115,9 +127,6 @@ const RunOnce: FC<IRunOnceProps> = ({
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
<FileUploaderInAttachmentWrapper
|
|
||||||
onChange={files => onVisionFilesChange(getProcessedFiles(files))}
|
|
||||||
/>
|
|
||||||
{promptConfig.prompt_variables.length > 0 && (
|
{promptConfig.prompt_variables.length > 0 && (
|
||||||
<div className='mt-4 h-[1px] bg-gray-100'></div>
|
<div className='mt-4 h-[1px] bg-gray-100'></div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -18,6 +18,12 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
||||||
if (item.number)
|
if (item.number)
|
||||||
return ['number', item.number]
|
return ['number', item.number]
|
||||||
|
|
||||||
|
if (item.file)
|
||||||
|
return ['file', item.file]
|
||||||
|
|
||||||
|
if (item['file-list'])
|
||||||
|
return ['file-list', item['file-list']]
|
||||||
|
|
||||||
if (item.external_data_tool)
|
if (item.external_data_tool)
|
||||||
return [item.external_data_tool.type, item.external_data_tool]
|
return [item.external_data_tool.type, item.external_data_tool]
|
||||||
|
|
||||||
|
@ -55,6 +61,34 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
||||||
is_context_var,
|
is_context_var,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
else if (type === 'file') {
|
||||||
|
promptVariables.push({
|
||||||
|
key: content.variable,
|
||||||
|
name: content.label,
|
||||||
|
required: content.required,
|
||||||
|
type,
|
||||||
|
config: {
|
||||||
|
allowed_file_types: content.allowed_file_types,
|
||||||
|
allowed_file_extensions: content.allowed_file_extensions,
|
||||||
|
allowed_file_upload_methods: content.allowed_file_upload_methods,
|
||||||
|
number_limits: 1,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if (type === 'file-list') {
|
||||||
|
promptVariables.push({
|
||||||
|
key: content.variable,
|
||||||
|
name: content.label,
|
||||||
|
required: content.required,
|
||||||
|
type,
|
||||||
|
config: {
|
||||||
|
allowed_file_types: content.allowed_file_types,
|
||||||
|
allowed_file_extensions: content.allowed_file_extensions,
|
||||||
|
allowed_file_upload_methods: content.allowed_file_upload_methods,
|
||||||
|
number_limits: content.max_length,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
promptVariables.push({
|
promptVariables.push({
|
||||||
key: content.variable,
|
key: content.variable,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user