Skip to content

Commit

Permalink
add io.input.slider
Browse files Browse the repository at this point in the history
  • Loading branch information
danphilibin committed Jul 11, 2023
1 parent 751d2b9 commit 1058684
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
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 @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/ioSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit 1058684

Please sign in to comment.