mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 14:22:28 +08:00
* feat: add multi-provider model configuration - Add model config dialog for managing multiple AI providers - Support for OpenAI, Anthropic, Google, Azure, Bedrock, OpenRouter, DeepSeek, SiliconFlow, Ollama, and AI Gateway - Add model selector dropdown in chat panel header - Add API key validation endpoint - Add custom model ID input with keyboard navigation - Fix hover highlight in Command component - Add suggested models for each provider including latest Claude 4.5 series - Store configuration locally in browser * feat: improve model config UI and move selector to chat input - Move model selector from header to chat input (left of send button) - Add per-model validation status (queued, running, valid, invalid) - Filter model selector to only show verified models - Add editable model IDs in config dialog - Add custom model input field alongside suggested models dropdown - Fix hover states on provider buttons and select triggers - Update OpenAI suggested models with GPT-5 series - Add alert-dialog component for delete confirmation * refactor: revert shadcn component changes, apply hover fix at usage site * feat: add AWS credentials support for Bedrock provider - Add AWS Access Key ID, Secret Access Key, Region fields for Bedrock - Show different credential fields based on provider type - Update validation API to handle Bedrock with AWS credentials - Add region selector with common AWS regions * fix: reset Test button after validation completes * fix: reset validation button to Test after success * fix: complete bedrock support and UI/UX improvements - Add bedrock to ALLOWED_CLIENT_PROVIDERS for client credentials - Pass AWS credentials through full chain (headers → API → provider) - Replace non-existent GPT-5 models with real ones (o1, o3-mini) - Add accessibility: aria-labels, focus-visible rings, inline errors - Add more AWS regions (Ohio, London, Paris, Mumbai, Seoul, São Paulo) - Fix setTimeout cleanup with useRef on component unmount - Fix TypeScript type consistency in getSelectedAIConfig fallback * chore: remove unused code - Remove unused setAccessCodeRequired state in chat-panel.tsx - Remove unused getSelectedModel export in model-config.ts * fix: UI/UX improvements for model configuration dialog - Add gradient header styling with icon badge - Change Configuration section icon from Key to Settings2 - Add duplicate model detection with warning banner and inline removal - Filter out already-added models from suggestions dropdown - Add type-to-confirm for deleting providers with 3+ models - Enhance delete confirmation dialog with warning icon - Improve model selector discoverability (show model name + chevron) - Add truncation for long model names with title tooltip - Remove AI provider settings from Settings dialog (now in Model Config) - Extract ValidationButton into reusable component * fix: prevent duplicate model IDs within same provider - Block adding model if ID already exists in provider - Block editing model ID to match existing model in provider * fix: improve duplicate model ID notifications - Add toast notification when trying to add duplicate model - Allow free typing when editing model ID, validate on blur - Show warning toast instead of blocking input * fix: improve duplicate model validation UX in config dialog - Add inline error display for duplicate model IDs - Show red border on input when error exists - Validate on blur with shake animation for edit errors - Prevent saving empty model names - Clear errors when user starts typing - Simplify error styling (small red text, no heavy chips)
157 lines
4.1 KiB
TypeScript
157 lines
4.1 KiB
TypeScript
import { Cloud } from "lucide-react"
|
|
import type { ComponentProps, ReactNode } from "react"
|
|
import {
|
|
Command,
|
|
CommandDialog,
|
|
CommandEmpty,
|
|
CommandGroup,
|
|
CommandInput,
|
|
CommandItem,
|
|
CommandList,
|
|
CommandSeparator,
|
|
CommandShortcut,
|
|
} from "@/components/ui/command"
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
} from "@/components/ui/dialog"
|
|
import { cn } from "@/lib/utils"
|
|
|
|
export type ModelSelectorProps = ComponentProps<typeof Dialog>
|
|
|
|
export const ModelSelector = (props: ModelSelectorProps) => (
|
|
<Dialog {...props} />
|
|
)
|
|
|
|
export type ModelSelectorTriggerProps = ComponentProps<typeof DialogTrigger>
|
|
|
|
export const ModelSelectorTrigger = (props: ModelSelectorTriggerProps) => (
|
|
<DialogTrigger {...props} />
|
|
)
|
|
|
|
export type ModelSelectorContentProps = ComponentProps<typeof DialogContent> & {
|
|
title?: ReactNode
|
|
}
|
|
|
|
export const ModelSelectorContent = ({
|
|
className,
|
|
children,
|
|
title = "Model Selector",
|
|
...props
|
|
}: ModelSelectorContentProps) => (
|
|
<DialogContent className={cn("p-0", className)} {...props}>
|
|
<DialogTitle className="sr-only">{title}</DialogTitle>
|
|
<Command className="**:data-[slot=command-input-wrapper]:h-auto">
|
|
{children}
|
|
</Command>
|
|
</DialogContent>
|
|
)
|
|
|
|
export type ModelSelectorDialogProps = ComponentProps<typeof CommandDialog>
|
|
|
|
export const ModelSelectorDialog = (props: ModelSelectorDialogProps) => (
|
|
<CommandDialog {...props} />
|
|
)
|
|
|
|
export type ModelSelectorInputProps = ComponentProps<typeof CommandInput>
|
|
|
|
export const ModelSelectorInput = ({
|
|
className,
|
|
...props
|
|
}: ModelSelectorInputProps) => (
|
|
<CommandInput className={cn("h-auto py-3.5", className)} {...props} />
|
|
)
|
|
|
|
export type ModelSelectorListProps = ComponentProps<typeof CommandList>
|
|
|
|
export const ModelSelectorList = (props: ModelSelectorListProps) => (
|
|
<CommandList {...props} />
|
|
)
|
|
|
|
export type ModelSelectorEmptyProps = ComponentProps<typeof CommandEmpty>
|
|
|
|
export const ModelSelectorEmpty = (props: ModelSelectorEmptyProps) => (
|
|
<CommandEmpty {...props} />
|
|
)
|
|
|
|
export type ModelSelectorGroupProps = ComponentProps<typeof CommandGroup>
|
|
|
|
export const ModelSelectorGroup = (props: ModelSelectorGroupProps) => (
|
|
<CommandGroup {...props} />
|
|
)
|
|
|
|
export type ModelSelectorItemProps = ComponentProps<typeof CommandItem>
|
|
|
|
export const ModelSelectorItem = (props: ModelSelectorItemProps) => (
|
|
<CommandItem {...props} />
|
|
)
|
|
|
|
export type ModelSelectorShortcutProps = ComponentProps<typeof CommandShortcut>
|
|
|
|
export const ModelSelectorShortcut = (props: ModelSelectorShortcutProps) => (
|
|
<CommandShortcut {...props} />
|
|
)
|
|
|
|
export type ModelSelectorSeparatorProps = ComponentProps<
|
|
typeof CommandSeparator
|
|
>
|
|
|
|
export const ModelSelectorSeparator = (props: ModelSelectorSeparatorProps) => (
|
|
<CommandSeparator {...props} />
|
|
)
|
|
|
|
export type ModelSelectorLogoProps = Omit<
|
|
ComponentProps<"img">,
|
|
"src" | "alt"
|
|
> & {
|
|
provider: string
|
|
}
|
|
|
|
export const ModelSelectorLogo = ({
|
|
provider,
|
|
className,
|
|
...props
|
|
}: ModelSelectorLogoProps) => {
|
|
// Use Lucide icon for bedrock since models.dev doesn't have a good AWS icon
|
|
if (provider === "amazon-bedrock") {
|
|
return <Cloud className={cn("size-4", className)} />
|
|
}
|
|
|
|
return (
|
|
<img
|
|
{...props}
|
|
alt={`${provider} logo`}
|
|
className={cn("size-4 dark:invert", className)}
|
|
height={16}
|
|
src={`https://models.dev/logos/${provider}.svg`}
|
|
width={16}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export type ModelSelectorLogoGroupProps = ComponentProps<"div">
|
|
|
|
export const ModelSelectorLogoGroup = ({
|
|
className,
|
|
...props
|
|
}: ModelSelectorLogoGroupProps) => (
|
|
<div
|
|
className={cn(
|
|
"-space-x-1 flex shrink-0 items-center [&>img]:rounded-full [&>img]:bg-background [&>img]:p-px [&>img]:ring-1 dark:[&>img]:bg-foreground",
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
|
|
export type ModelSelectorNameProps = ComponentProps<"span">
|
|
|
|
export const ModelSelectorName = ({
|
|
className,
|
|
...props
|
|
}: ModelSelectorNameProps) => (
|
|
<span className={cn("flex-1 truncate text-left", className)} {...props} />
|
|
)
|