-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from dwhiffing/feature/model-switching
Added Chat window settings
- Loading branch information
Showing
11 changed files
with
275 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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 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 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,90 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
import { Label } from "@/components/ui/label"; | ||
import { | ||
Select, | ||
SelectContent, | ||
SelectItem, | ||
SelectTrigger, | ||
SelectValue, | ||
} from "@/components/ui/select"; | ||
import { Checkbox } from "./ui/checkbox"; | ||
import { MODELS } from "@/constants"; | ||
import { findModelKey } from "@/utils/utils"; | ||
|
||
type IChatSettingProps = { | ||
clearOnChange: boolean; | ||
onClearOnChange: (value: boolean) => void; | ||
modelName: string; | ||
onModelNameChange: (value: string) => void; | ||
}; | ||
|
||
export function ChatSettings(props: IChatSettingProps) { | ||
const { modelName, onModelNameChange, clearOnChange, onClearOnChange } = | ||
props; | ||
const [inferenceProvider, setInferenceProvider] = useState(() => { | ||
return findModelKey(modelName); | ||
}); | ||
|
||
const handleInferenceProviderChange = (value: keyof typeof MODELS) => { | ||
setInferenceProvider(value); | ||
}; | ||
|
||
return ( | ||
<div className="max-w-80 min-w-80 border-l p-4 overflow-y-auto"> | ||
<h3 className="font-semibold mb-4">Settings</h3> | ||
<div className="space-y-4"> | ||
<div> | ||
<Label htmlFor="inferenceProvider">Inference</Label> | ||
<Select | ||
value={inferenceProvider} | ||
onValueChange={handleInferenceProviderChange} | ||
> | ||
<SelectTrigger id="modelName"> | ||
<SelectValue placeholder="Select a provider" /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
{Object.keys(MODELS).map((i) => ( | ||
<SelectItem key={i} value={i}> | ||
{i} | ||
</SelectItem> | ||
))} | ||
</SelectContent> | ||
</Select> | ||
</div> | ||
{inferenceProvider && ( | ||
<div> | ||
<Label htmlFor="modelName">Model</Label> | ||
<Select value={modelName} onValueChange={onModelNameChange}> | ||
<SelectTrigger id="modelName"> | ||
<SelectValue placeholder="Select a model" /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
{MODELS[inferenceProvider].map((modelName) => ( | ||
<SelectItem key={modelName} value={modelName}> | ||
{modelName} | ||
</SelectItem> | ||
))} | ||
</SelectContent> | ||
</Select> | ||
</div> | ||
)} | ||
|
||
<div className="flex items-center space-x-2"> | ||
<Checkbox | ||
id="terms" | ||
checked={clearOnChange} | ||
onCheckedChange={onClearOnChange} | ||
/> | ||
<label | ||
htmlFor="terms" | ||
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" | ||
> | ||
Clear Chat on Model change | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains 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 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,30 @@ | ||
"use client" | ||
|
||
import * as React from "react" | ||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox" | ||
import { Check } from "lucide-react" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const Checkbox = React.forwardRef< | ||
React.ElementRef<typeof CheckboxPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<CheckboxPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", | ||
className | ||
)} | ||
{...props} | ||
> | ||
<CheckboxPrimitive.Indicator | ||
className={cn("flex items-center justify-center text-current")} | ||
> | ||
<Check className="h-4 w-4" /> | ||
</CheckboxPrimitive.Indicator> | ||
</CheckboxPrimitive.Root> | ||
)) | ||
Checkbox.displayName = CheckboxPrimitive.Root.displayName | ||
|
||
export { Checkbox } |
This file contains 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.