-
Notifications
You must be signed in to change notification settings - Fork 428
frontend: added temperature gauge to assistant form #901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e1012a5
feat(assistants_web): added temperature to agent settings
ezawadski e99f851
feat(assistants_web): use agent temperature for chat requests
ezawadski df82126
chore(assistants_web): removed not working ticks from slider component
ezawadski 3195de9
chore(assistants_web): refactored setter/getter with more verbose name
ezawadski 85beb4e
feat(backend): if no temperature is sent with chat request, use agent…
ezawadski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/interfaces/assistants_web/src/components/UI/Slider.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| 'use client'; | ||
|
|
||
| import { ChangeEvent, useEffect, useMemo } from 'react'; | ||
|
|
||
| import { InputLabel, Text } from '@/components/UI'; | ||
| import { cn } from '@/utils'; | ||
|
|
||
| type Props = { | ||
| label: string; | ||
| min: number; | ||
| max: number; | ||
| step: number; | ||
| value: number; | ||
| onChange: (value: number) => void; | ||
| showTicks?: boolean; | ||
| sublabel?: string; | ||
| className?: string; | ||
| tooltipLabel?: React.ReactNode; | ||
| formatValue?: (value: number) => string; | ||
| tickDescriptor?: (tickValue: number) => string; | ||
| }; | ||
|
|
||
| /** | ||
| * | ||
| * Renders a slider with a label, a minimum, maximum and step value, and optional subLabel and tooltip. | ||
| * Styling for the thumb is located in main.css | ||
| */ | ||
| export const Slider: React.FC<Props> = ({ | ||
| label, | ||
| sublabel, | ||
| min, | ||
| max, | ||
| step, | ||
| value, | ||
| onChange, | ||
| tooltipLabel, | ||
| formatValue, | ||
| showTicks = false, | ||
| tickDescriptor, | ||
| className = '', | ||
| }) => { | ||
| // if `max` is changed dynamically don't allow the value to surpass it | ||
| useEffect(() => { | ||
| if (value > max) onChange(Math.min(value, max)); | ||
| }, [max, onChange, value]); | ||
|
|
||
| // if `min` is changed dynamically don't allow the value to go below it | ||
| useEffect(() => { | ||
| if (value < min) onChange(Math.max(value, min)); | ||
| }, [min, onChange, value]); | ||
|
|
||
| const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
| const value = Number(e.target.value); | ||
|
|
||
| onChange(value); | ||
| }; | ||
|
|
||
| const ticks = useMemo(() => { | ||
| return Array.from({ length: (max - min) / step + 1 }, (_, i) => { | ||
| return i * step + min; | ||
| }); | ||
| }, [max, min, step]); | ||
|
|
||
| return ( | ||
| <div className={cn('flex flex-col space-y-4', className)}> | ||
| <div className="flex w-full items-center justify-between"> | ||
| <InputLabel label={label} tooltipLabel={tooltipLabel} sublabel={sublabel} /> | ||
| <Text>{formatValue ? formatValue(value) : value}</Text> | ||
| </div> | ||
| <div className="flex items-center"> | ||
| <input | ||
| type="range" | ||
| value={value} | ||
| max={max} | ||
| min={min} | ||
| step={step} | ||
| onChange={handleChange} | ||
| className={cn( | ||
| 'flex w-full cursor-pointer appearance-none items-center rounded-lg border outline-none active:cursor-grabbing', | ||
| 'focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-4 focus-visible:outline-volcanic-100' | ||
| )} | ||
| /> | ||
|
|
||
| {showTicks && ( | ||
| <div className="absolute -z-10 flex w-full cursor-pointer justify-between"> | ||
| {ticks.map((tick) => ( | ||
| <span key={tick} className="h-2 w-2 rounded-full bg-black" /> | ||
| ))} | ||
| </div> | ||
| )} | ||
| </div> | ||
| {tickDescriptor && ( | ||
| <div className="flex w-full justify-between"> | ||
| {ticks.map((tick) => ( | ||
| <Text styleAs="caption" className="text-volcanic-400" key={tick}> | ||
| {tickDescriptor(tick)} | ||
| </Text> | ||
| ))} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/interfaces/assistants_web/src/stores/slices/paramsSlice.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.