Skip to content

Commit

Permalink
Merge pull request #1321 from interval/input-slider
Browse files Browse the repository at this point in the history
Add `io.input.slider`
  • Loading branch information
jacobmischka authored Jul 13, 2023
2 parents 56792dd + 203deb9 commit 2f1b533
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
13 changes: 13 additions & 0 deletions src/classes/IOClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
36 changes: 36 additions & 0 deletions src/examples/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/ioSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit 2f1b533

Please sign in to comment.