Merge pull request #105 from langgenius/fix/not-support-num-input

fix: not support num input
This commit is contained in:
Joel
2024-09-04 18:04:16 +08:00
committed by GitHub
3 changed files with 24 additions and 0 deletions

View File

@ -122,6 +122,15 @@ const Welcome: FC<IWelcomeProps> = ({
onChange={(e) => { setInputs({ ...inputs, [item.key]: e.target.value }) }} onChange={(e) => { setInputs({ ...inputs, [item.key]: e.target.value }) }}
/> />
)} )}
{item.type === 'number' && (
<input
type="number"
className="block w-full p-2 text-gray-900 border border-gray-300 rounded-lg bg-gray-50 sm:text-xs focus:ring-blue-500 focus:border-blue-500 "
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
value={inputs[item.key]}
onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }}
/>
)}
</div> </div>
))} ))}
</div> </div>

View File

@ -37,6 +37,8 @@ export type UserInputFormItem = {
'text-input': TextTypeFormItem 'text-input': TextTypeFormItem
} | { } | {
'select': SelectTypeFormItem 'select': SelectTypeFormItem
} | {
'paragraph': TextTypeFormItem
} }
export const MessageRatings = ['like', 'dislike', null] as const export const MessageRatings = ['like', 'dislike', null] as const

View File

@ -24,8 +24,12 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
if (item['text-input']) if (item['text-input'])
return ['string', item['text-input']] return ['string', item['text-input']]
if (item.number)
return ['number', item.number]
return ['select', item.select] return ['select', item.select]
})() })()
if (type === 'string' || type === 'paragraph') { if (type === 'string' || type === 'paragraph') {
promptVariables.push({ promptVariables.push({
key: content.variable, key: content.variable,
@ -36,6 +40,15 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
options: [], options: [],
}) })
} }
else if (type === 'number') {
promptVariables.push({
key: content.variable,
name: content.label,
required: content.required,
type,
options: [],
})
}
else { else {
promptVariables.push({ promptVariables.push({
key: content.variable, key: content.variable,