From 10586847eb4d0e4f584c9e670037b24b819507df Mon Sep 17 00:00:00 2001 From: Dan Philibin Date: Tue, 11 Jul 2023 20:01:34 +0000 Subject: [PATCH 1/2] add io.input.slider --- src/classes/IOClient.ts | 13 +++++++++++++ src/examples/basic/index.ts | 36 ++++++++++++++++++++++++++++++++++++ src/ioSchema.ts | 12 ++++++++++++ 3 files changed, 61 insertions(+) diff --git a/src/classes/IOClient.ts b/src/classes/IOClient.ts index 9002b4b..3287bc5 100644 --- a/src/classes/IOClient.ts +++ b/src/classes/IOClient.ts @@ -778,6 +778,19 @@ export class IOClient { * ``` */ number: this.createIOMethod('INPUT_NUMBER'), + /** + * Requests a numeric value within a range using a slider input. + * + * **Usage:** + * + * ```typescript + * const amount = await io.input.range("Amount", { + * helpText: "Select a number between one and ten.", + * min: 1, + * max: 10, + * }); + */ + slider: this.createIOMethod('INPUT_SLIDER'), /** * Requests an email address. * diff --git a/src/examples/basic/index.ts b/src/examples/basic/index.ts index 51e8190..e8d0d5b 100644 --- a/src/examples/basic/index.ts +++ b/src/examples/basic/index.ts @@ -2182,6 +2182,42 @@ const interval = new Interval({ return selected }, + slider: async () => { + const { maxLength, temperature } = await io.group({ + text: io.input.text('Text input').optional(), + maxLength: io.input.slider('Maximum length', { + min: 1, + max: 2048, + step: 1, + defaultValue: 512, + }), + temperature: io.input.slider('Temperature', { + min: 0, + max: 2, + step: 0.01, + defaultValue: 1, + }), + topP: io.input.slider('Top P', { + min: 0, + max: 1, + step: 0.01, + defaultValue: 1, + helpText: + 'Controls diversity via nucleus sampling: 0.5 means half of all likelihood- weighted options are considered.', + }), + frequencyPenalty: io.input.slider('Frequency penalty', { + min: 0, + max: 2, + step: 0.01, + defaultValue: 2, + disabled: true, + helpText: + "How much to penalize new tokens based on their existing frequency in the text so far. Decreases the model's likelihood to repeat the same line verbatim.", + }), + }) + + return { maxLength, temperature } + }, tables: new Page({ name: 'Tables', routes: table_actions, diff --git a/src/ioSchema.ts b/src/ioSchema.ts index db0e25a..0fb5708 100644 --- a/src/ioSchema.ts +++ b/src/ioSchema.ts @@ -629,6 +629,18 @@ const INPUT_SCHEMA = { state: z.null(), returns: z.number(), }, + INPUT_SLIDER: { + props: z.object({ + min: z.number(), + max: z.number(), + step: z.optional(z.number()), + helpText: z.optional(z.string()), + defaultValue: z.optional(z.number()).nullable(), + disabled: z.optional(z.boolean().default(false)), + }), + state: z.null(), + returns: z.number(), + }, INPUT_URL: { props: z.object({ helpText: z.optional(z.string()), From 203deb90d0ac7d53d0e06f955be4af053a15e91a Mon Sep 17 00:00:00 2001 From: Jacob Mischka Date: Wed, 12 Jul 2023 16:22:17 -0500 Subject: [PATCH 2/2] Add python implementation and tests for input.slider --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fe4fec0..f5578dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@interval/sdk", - "version": "1.4.3", + "version": "1.5.0-dev", "description": "The frontendless framework for high growth companies. Interval automatically generates apps by inlining the UI in your backend code. It's a faster and more maintainable way to build internal tools, rapid prototypes, and more.", "homepage": "https://interval.com", "repository": {