mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
feat: completion support boolean
This commit is contained in:
@ -130,7 +130,7 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[
|
||||
} as any)
|
||||
return
|
||||
}
|
||||
if (item.type === 'number') {
|
||||
if (item.type === 'number' || item.type === 'boolean') {
|
||||
userInputs.push({
|
||||
number: {
|
||||
label: item.name,
|
||||
@ -172,3 +172,17 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[
|
||||
|
||||
return userInputs
|
||||
}
|
||||
|
||||
export const formatBooleanInputs = (useInputs: PromptVariable[] | null, inputs: Record<string, string | number | object | boolean>) => {
|
||||
if(!useInputs)
|
||||
return inputs
|
||||
const res = { ...(inputs || {}) }
|
||||
useInputs.forEach((item) => {
|
||||
const isBooleanInput = item.type === 'boolean'
|
||||
if (isBooleanInput) {
|
||||
// Convert boolean inputs to boolean type
|
||||
res[item.key] = !!res[item.key]
|
||||
}
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user