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": { diff --git a/src/classes/IOClient.ts b/src/classes/IOClient.ts index ae05a83..56d9642 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 f602fbf..0b4bfb9 100644 --- a/src/examples/basic/index.ts +++ b/src/examples/basic/index.ts @@ -2241,6 +2241,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 9b7058c..31a76e0 100644 --- a/src/ioSchema.ts +++ b/src/ioSchema.ts @@ -636,6 +636,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()),