Initial commit: 国土空间规划课程智能体 v1.0
单容器 Docker 架构的国土空间规划课程智能问答系统,集成 FastAPI 后端与 Next.js 前端。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuSeparator,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { ChevronDown, Cpu, Zap, Sparkles } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface ModelOption {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
provider: string;
|
||||
icon?: React.ComponentType<{ className?: string }>;
|
||||
}
|
||||
|
||||
interface ModelSelectorProps {
|
||||
selectedModel: string;
|
||||
onModelChange: (modelId: string) => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const models: ModelOption[] = [
|
||||
{
|
||||
id: "deepseek-ai/DeepSeek-V3",
|
||||
name: "DeepSeek-V3",
|
||||
description: "DeepSeek 最新版本,强大的推理能力",
|
||||
provider: "DeepSeek",
|
||||
icon: Sparkles,
|
||||
},
|
||||
{
|
||||
id: "Qwen/QwQ-32B",
|
||||
name: "QwQ-32B",
|
||||
description: "Qwen 量子化模型,高效推理",
|
||||
provider: "Qwen",
|
||||
icon: Zap,
|
||||
},
|
||||
];
|
||||
|
||||
export default function ModelSelector({
|
||||
selectedModel,
|
||||
onModelChange,
|
||||
className
|
||||
}: ModelSelectorProps) {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const selectedModelData = models.find(model => model.id === selectedModel) || models[0];
|
||||
const IconComponent = selectedModelData.icon || Cpu;
|
||||
|
||||
return (
|
||||
<DropdownMenu open={isOpen} onOpenChange={setIsOpen}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"h-9 px-3 text-sm font-medium",
|
||||
"border-border/50 bg-background/80 hover:bg-muted/50",
|
||||
"transition-all duration-200",
|
||||
className
|
||||
)}
|
||||
>
|
||||
<IconComponent className="w-4 h-4 mr-2" />
|
||||
<span className="hidden sm:inline">{selectedModelData.name}</span>
|
||||
<span className="sm:hidden">{selectedModelData.name.split(' ')[0]}</span>
|
||||
<ChevronDown className="w-3 h-3 ml-1 opacity-50" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start" className="w-64">
|
||||
<div className="px-2 py-1.5 text-xs font-medium text-muted-foreground">
|
||||
选择AI模型
|
||||
</div>
|
||||
<DropdownMenuSeparator />
|
||||
{models.map((model) => {
|
||||
const ModelIcon = model.icon || Cpu;
|
||||
const isSelected = model.id === selectedModel;
|
||||
|
||||
return (
|
||||
<DropdownMenuItem
|
||||
key={model.id}
|
||||
onClick={() => {
|
||||
onModelChange(model.id);
|
||||
setIsOpen(false);
|
||||
}}
|
||||
className={cn(
|
||||
"flex items-start space-x-3 p-3 cursor-pointer",
|
||||
isSelected && "bg-muted/50"
|
||||
)}
|
||||
>
|
||||
<ModelIcon className="w-4 h-4 mt-0.5 flex-shrink-0" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center space-x-2">
|
||||
<span className="font-medium text-sm">{model.name}</span>
|
||||
{isSelected && (
|
||||
<Badge variant="secondary" className="text-xs">
|
||||
已选择
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mt-0.5">
|
||||
{model.description}
|
||||
</p>
|
||||
<div className="flex items-center space-x-1 mt-1">
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{model.provider}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
})}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user