Skip to content

Commit 291e9a0

Browse files
authored
Merge pull request langgenius#105 from langgenius/fix/not-support-num-input
fix: not support num input
2 parents ef15747 + ac0e3e8 commit 291e9a0

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

app/components/welcome/index.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ const Welcome: FC<IWelcomeProps> = ({
122122
onChange={(e) => { setInputs({ ...inputs, [item.key]: e.target.value }) }}
123123
/>
124124
)}
125+
{item.type === 'number' && (
126+
<input
127+
type="number"
128+
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 "
129+
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
130+
value={inputs[item.key]}
131+
onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }}
132+
/>
133+
)}
125134
</div>
126135
))}
127136
</div>

types/app.ts

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export type UserInputFormItem = {
3737
'text-input': TextTypeFormItem
3838
} | {
3939
'select': SelectTypeFormItem
40+
} | {
41+
'paragraph': TextTypeFormItem
4042
}
4143

4244
export const MessageRatings = ['like', 'dislike', null] as const

utils/prompt.ts

+13
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
2424
if (item['text-input'])
2525
return ['string', item['text-input']]
2626

27+
if (item.number)
28+
return ['number', item.number]
29+
2730
return ['select', item.select]
2831
})()
32+
2933
if (type === 'string' || type === 'paragraph') {
3034
promptVariables.push({
3135
key: content.variable,
@@ -36,6 +40,15 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
3640
options: [],
3741
})
3842
}
43+
else if (type === 'number') {
44+
promptVariables.push({
45+
key: content.variable,
46+
name: content.label,
47+
required: content.required,
48+
type,
49+
options: [],
50+
})
51+
}
3952
else {
4053
promptVariables.push({
4154
key: content.variable,

0 commit comments

Comments
 (0)