mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 03:55:52 +08:00
fix: code-based extension (#2490)
This commit is contained in:
parent
eedbe1b770
commit
297d0f1f30
@ -147,6 +147,7 @@ const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVar
|
|||||||
) => {
|
) => {
|
||||||
setShowExternalDataToolModal({
|
setShowExternalDataToolModal({
|
||||||
payload: {
|
payload: {
|
||||||
|
type,
|
||||||
variable: key,
|
variable: key,
|
||||||
label: name,
|
label: name,
|
||||||
config,
|
config,
|
||||||
@ -245,7 +246,7 @@ const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVar
|
|||||||
|
|
||||||
const handleConfig = ({ key, type, index, name, config, icon, icon_background }: ExternalDataToolParams) => {
|
const handleConfig = ({ key, type, index, name, config, icon, icon_background }: ExternalDataToolParams) => {
|
||||||
setCurrKey(key)
|
setCurrKey(key)
|
||||||
if (type === 'api') {
|
if (type !== 'string' && type !== 'paragraph' && type !== 'select') {
|
||||||
handleOpenExternalDataToolModal({ key, type, index, name, config, icon, icon_background }, promptVariables)
|
handleOpenExternalDataToolModal({ key, type, index, name, config, icon, icon_background }, promptVariables)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ const Debug: FC<IDebug> = ({
|
|||||||
}
|
}
|
||||||
let hasEmptyInput = ''
|
let hasEmptyInput = ''
|
||||||
const requiredVars = modelConfig.configs.prompt_variables.filter(({ key, name, required, type }) => {
|
const requiredVars = modelConfig.configs.prompt_variables.filter(({ key, name, required, type }) => {
|
||||||
if (type === 'api')
|
if (type !== 'string' && type !== 'paragraph' && type !== 'select')
|
||||||
return false
|
return false
|
||||||
const res = (!key || !key.trim()) || (!name || !name.trim()) || (required || required === undefined || required === null)
|
const res = (!key || !key.trim()) || (!name || !name.trim()) || (required || required === undefined || required === null)
|
||||||
return res
|
return res
|
||||||
|
@ -65,7 +65,7 @@ const FormGeneration: FC<FormGenerationProps> = ({
|
|||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
onSelect={item => handleFormChange(form.variable, item.value as string)}
|
onSelect={item => handleFormChange(form.variable, item.value as string)}
|
||||||
popupClassName='w-[576px]'
|
popupClassName='w-[576px] !z-[102]'
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ export const useCheckPromptVariables = () => {
|
|||||||
} = promptVariablesConfig
|
} = promptVariablesConfig
|
||||||
let hasEmptyInput = ''
|
let hasEmptyInput = ''
|
||||||
const requiredVars = promptVariables.filter(({ key, name, required, type }) => {
|
const requiredVars = promptVariables.filter(({ key, name, required, type }) => {
|
||||||
if (type === 'api')
|
if (type !== 'string' && type !== 'paragraph' && type !== 'select')
|
||||||
return false
|
return false
|
||||||
const res = (!key || !key.trim()) || (!name || !name.trim()) || (required || required === undefined || required === null)
|
const res = (!key || !key.trim()) || (!name || !name.trim()) || (required || required === undefined || required === null)
|
||||||
return res
|
return res
|
||||||
|
@ -16,7 +16,7 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
|||||||
return ['string', item['text-input']]
|
return ['string', item['text-input']]
|
||||||
|
|
||||||
if (item.external_data_tool)
|
if (item.external_data_tool)
|
||||||
return ['api', item.external_data_tool]
|
return [item.external_data_tool.type, item.external_data_tool]
|
||||||
|
|
||||||
return ['select', item.select]
|
return ['select', item.select]
|
||||||
})()
|
})()
|
||||||
@ -33,7 +33,17 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
|||||||
is_context_var,
|
is_context_var,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else if (type === 'api') {
|
else if (type === 'select') {
|
||||||
|
promptVariables.push({
|
||||||
|
key: content.variable,
|
||||||
|
name: content.label,
|
||||||
|
required: content.required,
|
||||||
|
type: 'select',
|
||||||
|
options: content.options,
|
||||||
|
is_context_var,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
promptVariables.push({
|
promptVariables.push({
|
||||||
key: content.variable,
|
key: content.variable,
|
||||||
name: content.label,
|
name: content.label,
|
||||||
@ -46,16 +56,6 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
|||||||
is_context_var,
|
is_context_var,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
promptVariables.push({
|
|
||||||
key: content.variable,
|
|
||||||
name: content.label,
|
|
||||||
required: content.required,
|
|
||||||
type: 'select',
|
|
||||||
options: content.options,
|
|
||||||
is_context_var,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return promptVariables
|
return promptVariables
|
||||||
}
|
}
|
||||||
@ -79,7 +79,18 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[
|
|||||||
},
|
},
|
||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
else if (item.type === 'api') {
|
else if (item.type === 'select') {
|
||||||
|
userInputs.push({
|
||||||
|
select: {
|
||||||
|
label: item.name,
|
||||||
|
variable: item.key,
|
||||||
|
required: item.required !== false, // default true
|
||||||
|
options: item.options,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
else {
|
||||||
userInputs.push({
|
userInputs.push({
|
||||||
external_data_tool: {
|
external_data_tool: {
|
||||||
label: item.name,
|
label: item.name,
|
||||||
@ -93,17 +104,6 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[
|
|||||||
},
|
},
|
||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
userInputs.push({
|
|
||||||
select: {
|
|
||||||
label: item.name,
|
|
||||||
variable: item.key,
|
|
||||||
required: item.required !== false, // default true
|
|
||||||
options: item.options,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
} as any)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return userInputs
|
return userInputs
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user