From 9b2d75239a717c2dd67b6dbdbcf3fd65c6ca174f Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 7 Aug 2024 16:24:45 +0800 Subject: [PATCH] feat: support number field --- app/components/config-scence/index.tsx | 9 +++++++++ app/components/run-once/index.tsx | 9 +++++++++ package.json | 2 +- utils/prompt.ts | 12 ++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/components/config-scence/index.tsx b/app/components/config-scence/index.tsx index 84881bd..83933cd 100644 --- a/app/components/config-scence/index.tsx +++ b/app/components/config-scence/index.tsx @@ -68,6 +68,15 @@ const ConfigSence: FC = ({ onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }} /> )} + {item.type === 'number' && ( + { onInputsChange({ ...inputs, [item.key]: e.target.value }) }} + /> + )} ))} diff --git a/app/components/run-once/index.tsx b/app/components/run-once/index.tsx index 0901fd7..4e94f31 100644 --- a/app/components/run-once/index.tsx +++ b/app/components/run-once/index.tsx @@ -73,6 +73,15 @@ const RunOnce: FC = ({ onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }} /> )} + {item.type === 'number' && ( + { onInputsChange({ ...inputs, [item.key]: e.target.value }) }} + /> + )} ))} diff --git a/package.json b/package.json index 357dda4..4e8f73f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "js-cookie": "^3.0.1", "katex": "^0.16.7", "negotiator": "^0.6.3", - "next": "^14.0.4", + "next": "^14.1.1", "react": "18.2.0", "react-dom": "18.2.0", "react-error-boundary": "^4.0.2", diff --git a/utils/prompt.ts b/utils/prompt.ts index d851ea0..06bae14 100644 --- a/utils/prompt.ts +++ b/utils/prompt.ts @@ -24,6 +24,9 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] | if (item['text-input']) return ['string', item['text-input']] + if (item.number) + return ['number', item.number] + return ['select', item.select] })() if (type === 'string' || type === 'paragraph') { @@ -36,6 +39,15 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] | options: [], }) } + else if (type === 'number') { + promptVariables.push({ + key: content.variable, + name: content.label, + required: content.required, + type, + options: [], + }) + } else { promptVariables.push({ key: content.variable,