-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
25,634 additions
and
89 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
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,60 @@ | ||
import React from 'react'; | ||
import { useStore } from '@nanostores/react'; | ||
import { providerStore, setProvider, type Provider } from '~/lib/stores/provider'; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuTrigger, | ||
DropdownMenuContent, | ||
DropdownMenuRadioGroup, | ||
DropdownMenuRadioItem, | ||
} from '~/components/ui/dropdown-menu'; | ||
import { Button } from '~/components/ui/button'; | ||
import '~/styles/index.scss'; | ||
import { ChevronDownIcon } from '@radix-ui/react-icons'; | ||
|
||
export function ProviderSelector() { | ||
const currentProvider = useStore(providerStore); | ||
|
||
const handleProviderChange = (value: string) => { | ||
if (value === 'anthropic') { | ||
setProvider('anthropic'); | ||
} else { | ||
setProvider({ type: 'together', model: value }); | ||
} | ||
}; | ||
|
||
const togetherModels = [ | ||
'meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo', | ||
'meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo', | ||
'mistralai/Mixtral-8x7B-Instruct-v0.1', | ||
// Add more Together AI models here | ||
]; | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" className="w-[250px] justify-between bg-transparent border-none ring-transparent outline-transparent text-white hover:text-white/80 truncate"> | ||
{currentProvider === 'anthropic' | ||
? 'Anthropic (Claude)' | ||
: `Together AI (${currentProvider.model})`} | ||
<ChevronDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent className="w-[250px] bg-black text-white border-none"> | ||
<DropdownMenuRadioGroup | ||
value={currentProvider === 'anthropic' ? 'anthropic' : currentProvider.model} | ||
onValueChange={handleProviderChange} | ||
> | ||
<DropdownMenuRadioItem value="anthropic" className="hover:bg-white/10"> | ||
Anthropic (Claude) | ||
</DropdownMenuRadioItem> | ||
{togetherModels.map(model => ( | ||
<DropdownMenuRadioItem key={model} value={model} className="hover:bg-white/10"> | ||
Together AI ({model}) | ||
</DropdownMenuRadioItem> | ||
))} | ||
</DropdownMenuRadioGroup> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
} |
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,57 @@ | ||
import * as React from "react" | ||
import { Slot } from "@radix-ui/react-slot" | ||
import { cva, type VariantProps } from "class-variance-authority" | ||
|
||
import { cn } from "~/lib/utils" | ||
|
||
const buttonVariants = cva( | ||
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50", | ||
{ | ||
variants: { | ||
variant: { | ||
default: | ||
"bg-primary text-primary-foreground shadow hover:bg-primary/90", | ||
destructive: | ||
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90", | ||
outline: | ||
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", | ||
secondary: | ||
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", | ||
ghost: "hover:bg-accent hover:text-accent-foreground", | ||
link: "text-primary underline-offset-4 hover:underline", | ||
}, | ||
size: { | ||
default: "h-9 px-4 py-2", | ||
sm: "h-8 rounded-md px-3 text-xs", | ||
lg: "h-10 rounded-md px-8", | ||
icon: "h-9 w-9", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "default", | ||
size: "default", | ||
}, | ||
} | ||
) | ||
|
||
export interface ButtonProps | ||
extends React.ButtonHTMLAttributes<HTMLButtonElement>, | ||
VariantProps<typeof buttonVariants> { | ||
asChild?: boolean | ||
} | ||
|
||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( | ||
({ className, variant, size, asChild = false, ...props }, ref) => { | ||
const Comp = asChild ? Slot : "button" | ||
return ( | ||
<Comp | ||
className={cn(buttonVariants({ variant, size, className }))} | ||
ref={ref} | ||
{...props} | ||
/> | ||
) | ||
} | ||
) | ||
Button.displayName = "Button" | ||
|
||
export { Button, buttonVariants } |
Oops, something went wrong.