feat: completion support boolean

This commit is contained in:
Joel
2025-07-09 14:28:36 +08:00
parent b5782fff8f
commit 8c8c250570
3 changed files with 33 additions and 8 deletions

View File

@ -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
}