diff --git a/app/client/api.ts b/app/client/api.ts index d05909a8..b04cf9b8 100644 --- a/app/client/api.ts +++ b/app/client/api.ts @@ -1,5 +1,6 @@ import { ChatCompletionFinishReason, CompletionUsage } from "@mlc-ai/web-llm"; import { CacheType, Model } from "../store"; +import { ModelFamily } from "../constant"; export const ROLES = ["system", "user", "assistant"] as const; export type MessageRole = (typeof ROLES)[number]; @@ -58,7 +59,7 @@ export interface ModelRecord { provider?: string; size?: string; quantization?: string; - family?: string; + family: ModelFamily; recommended_config?: { temperature?: number; context_window_size?: number; diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 4572c22d..830564b2 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -68,11 +68,9 @@ import { ListItem, Modal, Popover, - Selector, showConfirm, showPrompt, showToast, - Tooltip, } from "./ui-lib"; import { useNavigate } from "react-router-dom"; import { @@ -83,7 +81,7 @@ import { UNFINISHED_INPUT, } from "../constant"; import { Avatar, AvatarPicker } from "./emoji"; -import { ContextPrompts, TemplateAvatar, TemplateConfig } from "./template"; +import { ContextPrompts, TemplateAvatar } from "./template"; import { ChatCommandPrefix, useChatCommand, useCommand } from "../command"; import { prettyObject } from "../utils/format"; import { ExportMessageModal } from "./exporter"; @@ -91,8 +89,8 @@ import { MultimodalContent } from "../client/api"; import { Template, useTemplateStore } from "../store/template"; import Image from "next/image"; import { MLCLLMContext, WebLLMContext } from "../context"; -import EyeIcon from "../icons/eye.svg"; import { ChatImage } from "../typing"; +import ModelSelect from "./model-select"; export function ScrollDownToast(prop: { show: boolean; onclick: () => void }) { return ( @@ -544,23 +542,14 @@ export function ChatActions(props: { fullWidth /> {showModelSelector && ( - ({ - title: m.name, - value: m.name, - family: m.family, - icon: isVisionModel(m.name) ? ( - Vision Model} direction="bottom"> - - - ) : undefined, - }))} - onClose={() => setShowModelSelector(false)} - onSelection={(s) => { - if (s.length === 0) return; - config.selectModel(s[0] as Model); - showToast(s[0]); + { + setShowModelSelector(false); + }} + availableModels={models.map((m) => m.name)} + onSelectModel={(modelName) => { + config.selectModel(modelName as Model); + showToast(modelName); }} /> )} diff --git a/app/components/model-config.tsx b/app/components/model-config.tsx index 229c9c73..2ea8a068 100644 --- a/app/components/model-config.tsx +++ b/app/components/model-config.tsx @@ -3,6 +3,7 @@ import { ModelConfig, useAppConfig, ModelClient, + Model, } from "../store"; import CancelIcon from "../icons/cancel.svg"; @@ -11,13 +12,15 @@ import ConnectIcon from "../icons/connection.svg"; import Locale from "../locales"; import { InputRange } from "./input-range"; -import { List, ListItem, Modal, Select } from "./ui-lib"; +import { List, ListItem, Modal, Select, showToast } from "./ui-lib"; import React, { useState } from "react"; import { IconButton } from "./button"; +import ModelSelect from "./model-select"; export function ModelConfigList() { const config = useAppConfig(); const models = config.models; + const [showModelSelector, setShowModelSelector] = useState(false); const [showApiConnectModel, setShowApiConnectModel] = useState(false); const [endpointInput, setEndpointInput] = useState( @@ -59,8 +62,13 @@ export function ModelConfigList() { setSearchTerm(e.target.value)} + className={style["input"]} + /> + + + ); +}; + +const ModelSelect: React.FC = ({ + onClose, + availableModels, + onSelectModel, +}) => { + const config = useAppConfig(); + const [searchTerm, setSearchTerm] = useState(""); + const [filteredModels, setFilteredModels] = useState<[string, string[]][]>( + [], + ); + const [selectedFamilies, setSelectedFamilies] = useState([]); + const [expandedModels, setExpandedModels] = useState>(new Set()); + + const determineModelIcon = (model: Model) => { + const modelFamily = identifyModelFamily(model); + const modelDetail = modelDetailsList.find( + (md) => modelFamily && modelFamily === md.family, + ); + console.log(model, modelFamily, modelDetail); + return ( +
+ {modelDetail?.icon ? : } +
+ ); + }; + + const identifyModelFamily = (model: Model): ModelFamily | null => { + return config.models.find((m) => m.name === model)?.family || null; + }; + + const extractModelDetails = (model: string) => { + const parts = model.split("-"); + const displayName: string[] = []; + const quantBadges: string[] = []; + let isBadge = false; + + for (let i = 0; i < parts.length; i++) { + const part = parts[i]; + if (isBadge || part.startsWith("q") || part.startsWith("b")) { + isBadge = true; + if (part !== "MLC") { + quantBadges.push(part); + } + } else { + displayName.push(part); + } + } + + return { + displayName: displayName.join(" "), + quantBadge: quantBadges.length > 0 ? quantBadges.join("-") : null, + }; + }; + + const sortAndGroupModels = useCallback( + (models: string[]): [string, string[]][] => { + const groupedModels: { [key: string]: string[] } = {}; + + for (const model of models) { + const { displayName } = extractModelDetails(model); + const family = identifyModelFamily(model); + + if (family) { + if (!groupedModels[displayName]) { + groupedModels[displayName] = []; + } + groupedModels[displayName].push(model); + } + } + + for (const key in groupedModels) { + groupedModels[key].sort((a, b) => a.localeCompare(b)); + } + + return Object.entries(groupedModels).sort( + ([, aVariants], [, bVariants]) => { + const familyA = identifyModelFamily(aVariants[0]) || ""; + const familyB = identifyModelFamily(bVariants[0]) || ""; + return familyA.localeCompare(familyB); + }, + ); + }, + [], + ); + + const handleToggleExpand = (modelName: string) => { + setExpandedModels((prev) => { + const updatedSet = new Set(prev); + if (updatedSet.has(modelName)) { + updatedSet.delete(modelName); + } else { + updatedSet.add(modelName); + } + return updatedSet; + }); + }; + + useEffect(() => { + const sortedModels = sortAndGroupModels(availableModels); + + let filtered = sortedModels; + + if (searchTerm) { + const lowerSearchTerm = searchTerm.toLowerCase(); + filtered = sortedModels.filter( + ([baseModel, variants]) => + baseModel.toLowerCase().includes(lowerSearchTerm) || + variants.some((v) => v.toLowerCase().includes(lowerSearchTerm)), + ); + } + + if (selectedFamilies.length > 0) { + filtered = filtered.filter(([, variants]) => { + const family = identifyModelFamily(variants[0]); + return family && selectedFamilies.includes(family); + }); + } + + setFilteredModels(filtered); + }, [searchTerm, availableModels, selectedFamilies, sortAndGroupModels]); + + const handleToggleFamilyFilter = (family: string) => { + setSelectedFamilies((prev) => + prev.includes(family) + ? prev.filter((f) => f !== family) + : [...prev, family], + ); + }; + + const searchInputRef = useRef(null); + + useEffect(() => { + setTimeout(() => { + searchInputRef.current?.focus(); + }, 0); + }, []); + + const countModelsPerFamily = ( + models: string[], + ): { [key: string]: number } => { + const counts: { [key: string]: number } = {}; + for (const model of models) { + const family = identifyModelFamily(model); + if (family) { + counts[family] = (counts[family] || 0) + 1; + } + } + return counts; + }; + + const modelCounts = countModelsPerFamily(availableModels); + const sortedModelFamilies = Object.entries(modelFamilies).sort( + ([a], [b]) => (modelCounts[b] || 0) - (modelCounts[a] || 0), + ); + + return ( +
+ +
+ +
+ {sortedModelFamilies.map(([key, { name, icon: Icon }]) => ( + handleToggleFamilyFilter(key)} + bordered + text={name} + icon={ +
+ {Icon ? : } +
+ } + className={style["model-family-button"]} + /> + ))} +
+
+
+ {filteredModels.map((model) => ( + + ))} +
+
+
+ ); +}; + +export default ModelSelect; diff --git a/app/constant.ts b/app/constant.ts index 1ec075a5..2075b5b8 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -66,13 +66,25 @@ Latex inline format: \\(x^2\\) Latex block format: $$e=mc^2$$ `; +export enum ModelFamily { + LLAMA = "llama", + PHI = "phi", + MISTRAL = "mistral", + GEMMA = "gemma", + QWEN = "qwen", + SMOL_LM = "smollm", + WIZARD_MATH = "wizardmath", + STABLE_LM = "stablelm", + REDPAJAMA = "redpajama", +} + const DEFAULT_MODEL_BASES: ModelRecord[] = [ // Phi-3.5 Vision { name: "Phi-3.5-vision-instruct-q4f32_1-MLC", display_name: "Phi", provider: "Microsoft", - family: "Phi 3.5 Vision", + family: ModelFamily.PHI, recommended_config: { temperature: 1, presence_penalty: 0, @@ -84,7 +96,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Phi-3.5-vision-instruct-q4f16_1-MLC", display_name: "Phi", provider: "Microsoft", - family: "Phi 3.5 Vision", + family: ModelFamily.PHI, recommended_config: { temperature: 1, presence_penalty: 0, @@ -97,7 +109,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.2-1B-Instruct-q4f32_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3.2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -109,7 +121,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.2-1B-Instruct-q4f16_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3.2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -121,7 +133,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.2-1B-Instruct-q0f32-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3.2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -133,7 +145,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.2-1B-Instruct-q0f16-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3.2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -145,7 +157,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.2-3B-Instruct-q4f32_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3.2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -157,7 +169,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.2-3B-Instruct-q4f16_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3.2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -170,7 +182,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.1-8B-Instruct-q4f32_1-MLC-1k", display_name: "Llama", provider: "Meta", - family: "Llama 3.1", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -182,7 +194,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.1-8B-Instruct-q4f16_1-MLC-1k", display_name: "Llama", provider: "Meta", - family: "Llama 3.1", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -194,7 +206,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.1-8B-Instruct-q4f32_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3.1", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -206,7 +218,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.1-8B-Instruct-q4f16_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3.1", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -218,7 +230,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Hermes-2-Pro-Llama-3-8B-q4f16_1-MLC", display_name: "Hermes", provider: "NousResearch", - family: "Hermes 2 Pro", + family: ModelFamily.LLAMA, recommended_config: { temperature: 1, presence_penalty: 0, @@ -230,7 +242,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Hermes-2-Pro-Llama-3-8B-q4f32_1-MLC", display_name: "Hermes", provider: "NousResearch", - family: "Hermes 2 Pro", + family: ModelFamily.LLAMA, recommended_config: { temperature: 1, presence_penalty: 0, @@ -242,7 +254,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Hermes-3-Llama-3.1-8B-q4f32_1-MLC", display_name: "Hermes", provider: "NousResearch", - family: "Hermes 3", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -254,7 +266,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Hermes-3-Llama-3.1-8B-q4f16_1-MLC", display_name: "Hermes", provider: "NousResearch", - family: "Hermes 3", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -266,7 +278,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Hermes-2-Pro-Mistral-7B-q4f16_1-MLC", display_name: "Hermes", provider: "NousResearch", - family: "Hermes 2 Pro", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -278,7 +290,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Phi-3.5-mini-instruct-q4f16_1-MLC", display_name: "Phi", provider: "Microsoft", - family: "Phi 3.5 Mini", + family: ModelFamily.PHI, recommended_config: { temperature: 1, presence_penalty: 0, @@ -290,7 +302,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Phi-3.5-mini-instruct-q4f32_1-MLC", display_name: "Phi", provider: "Microsoft", - family: "Phi 3.5 Mini", + family: ModelFamily.PHI, recommended_config: { temperature: 1, presence_penalty: 0, @@ -302,7 +314,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Phi-3.5-mini-instruct-q4f16_1-MLC-1k", display_name: "Phi", provider: "Microsoft", - family: "Phi 3.5 Mini", + family: ModelFamily.PHI, recommended_config: { temperature: 1, presence_penalty: 0, @@ -314,7 +326,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Phi-3.5-mini-instruct-q4f32_1-MLC-1k", display_name: "Phi", provider: "Microsoft", - family: "Phi 3.5 Mini", + family: ModelFamily.PHI, recommended_config: { temperature: 1, presence_penalty: 0, @@ -326,7 +338,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Mistral-7B-Instruct-v0.3-q4f16_1-MLC", display_name: "Mistral", provider: "Mistral AI", - family: "Mistral", + family: ModelFamily.MISTRAL, recommended_config: { temperature: 1, presence_penalty: 0, @@ -338,7 +350,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Mistral-7B-Instruct-v0.3-q4f32_1-MLC", display_name: "Mistral", provider: "Mistral AI", - family: "Mistral", + family: ModelFamily.MISTRAL, recommended_config: { temperature: 1, presence_penalty: 0, @@ -350,7 +362,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Mistral-7B-Instruct-v0.2-q4f16_1-MLC", display_name: "Mistral", provider: "Mistral AI", - family: "Mistral", + family: ModelFamily.MISTRAL, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -360,7 +372,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "OpenHermes-2.5-Mistral-7B-q4f16_1-MLC", display_name: "OpenHermes", provider: "NousResearch", - family: "Hermes", + family: ModelFamily.MISTRAL, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -370,7 +382,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "NeuralHermes-2.5-Mistral-7B-q4f16_1-MLC", display_name: "NeuralHermes", provider: "Maxime Labonne", - family: "Hermes", + family: ModelFamily.MISTRAL, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -380,7 +392,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "WizardMath-7B-V1.1-q4f16_1-MLC", display_name: "WizardMath", provider: "WizardLM", - family: "WizardMath", + family: ModelFamily.WIZARD_MATH, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -391,7 +403,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "SmolLM2-1.7B-Instruct-q4f16_1-MLC", display_name: "SmolLM", provider: "HuggingFaceTB", - family: "SmolLM2", + family: ModelFamily.SMOL_LM, recommended_config: { temperature: 1, presence_penalty: 0, @@ -403,7 +415,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "SmolLM2-1.7B-Instruct-q4f32_1-MLC", display_name: "SmolLM", provider: "HuggingFaceTB", - family: "SmolLM2", + family: ModelFamily.SMOL_LM, recommended_config: { temperature: 1, presence_penalty: 0, @@ -415,7 +427,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "SmolLM2-360M-Instruct-q0f16-MLC", display_name: "SmolLM", provider: "HuggingFaceTB", - family: "SmolLM2", + family: ModelFamily.SMOL_LM, recommended_config: { temperature: 1, presence_penalty: 0, @@ -427,7 +439,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "SmolLM2-360M-Instruct-q0f32-MLC", display_name: "SmolLM", provider: "HuggingFaceTB", - family: "SmolLM2", + family: ModelFamily.SMOL_LM, recommended_config: { temperature: 1, presence_penalty: 0, @@ -439,7 +451,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "SmolLM2-360M-Instruct-q4f16_1-MLC", display_name: "SmolLM", provider: "HuggingFaceTB", - family: "SmolLM2", + family: ModelFamily.SMOL_LM, recommended_config: { temperature: 1, presence_penalty: 0, @@ -451,7 +463,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "SmolLM2-360M-Instruct-q4f32_1-MLC", display_name: "SmolLM", provider: "HuggingFaceTB", - family: "SmolLM2", + family: ModelFamily.SMOL_LM, recommended_config: { temperature: 1, presence_penalty: 0, @@ -463,7 +475,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "SmolLM2-135M-Instruct-q0f16-MLC", display_name: "SmolLM", provider: "HuggingFaceTB", - family: "SmolLM2", + family: ModelFamily.SMOL_LM, recommended_config: { temperature: 1, presence_penalty: 0, @@ -475,7 +487,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "SmolLM2-135M-Instruct-q0f32-MLC", display_name: "SmolLM", provider: "HuggingFaceTB", - family: "SmolLM2", + family: ModelFamily.SMOL_LM, recommended_config: { temperature: 1, presence_penalty: 0, @@ -487,7 +499,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-0.5B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -499,7 +511,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-0.5B-Instruct-q4f32_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -511,7 +523,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-0.5B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -523,7 +535,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-0.5B-Instruct-q0f16-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -535,7 +547,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-0.5B-Instruct-q0f32-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -547,7 +559,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-1.5B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -559,7 +571,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-1.5B-Instruct-q4f32_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -571,7 +583,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-3B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -583,7 +595,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-3B-Instruct-q4f32_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -595,7 +607,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-7B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -607,7 +619,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-7B-Instruct-q4f32_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -620,7 +632,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-Coder-1.5B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5 Coder", + family: ModelFamily.QWEN, recommended_config: { temperature: 1.0, presence_penalty: 0, @@ -632,7 +644,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-Coder-1.5B-Instruct-q4f32_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5 Coder", + family: ModelFamily.QWEN, recommended_config: { temperature: 1.0, presence_penalty: 0, @@ -644,7 +656,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-Coder-7B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5 Coder", + family: ModelFamily.QWEN, recommended_config: { temperature: 1.0, presence_penalty: 0, @@ -656,7 +668,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2.5-Coder-7B-Instruct-q4f32_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2.5 Coder", + family: ModelFamily.QWEN, recommended_config: { temperature: 1.0, presence_penalty: 0, @@ -669,7 +681,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-Math-1.5B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2 Math", + family: ModelFamily.QWEN, recommended_config: { temperature: 1.0, presence_penalty: 0, @@ -681,7 +693,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-Math-1.5B-Instruct-q4f32_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2 Math", + family: ModelFamily.QWEN, recommended_config: { temperature: 1.0, presence_penalty: 0, @@ -693,7 +705,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-Math-7B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2 Math", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -705,7 +717,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-Math-7B-Instruct-q4f32_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2 Math", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -717,7 +729,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "gemma-2-2b-it-q4f16_1-MLC", display_name: "Gemma", provider: "Google", - family: "Gemma", + family: ModelFamily.GEMMA, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -729,7 +741,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "gemma-2-2b-it-q4f32_1-MLC", display_name: "Gemma", provider: "Google", - family: "Gemma", + family: ModelFamily.GEMMA, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -741,7 +753,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "gemma-2-2b-it-q4f16_1-MLC-1k", display_name: "Gemma", provider: "Google", - family: "Gemma", + family: ModelFamily.GEMMA, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -753,7 +765,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "gemma-2-2b-it-q4f32_1-MLC-1k", display_name: "Gemma", provider: "Google", - family: "Gemma", + family: ModelFamily.GEMMA, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -765,7 +777,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "gemma-2-9b-it-q4f16_1-MLC", display_name: "Gemma", provider: "Google", - family: "Gemma", + family: ModelFamily.GEMMA, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -777,7 +789,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "gemma-2-9b-it-q4f32_1-MLC", display_name: "Gemma", provider: "Google", - family: "Gemma", + family: ModelFamily.GEMMA, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -789,7 +801,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "gemma-2-2b-jpn-it-q4f16_1-MLC", display_name: "Gemma", provider: "Google", - family: "Gemma", + family: ModelFamily.GEMMA, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -801,7 +813,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "gemma-2-2b-jpn-it-q4f32_1-MLC", display_name: "Gemma", provider: "Google", - family: "Gemma", + family: ModelFamily.GEMMA, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -813,7 +825,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "stablelm-2-zephyr-1_6b-q4f16_1-MLC", display_name: "StableLM", provider: "Hugging Face", - family: "StableLM 2", + family: ModelFamily.STABLE_LM, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -825,7 +837,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "stablelm-2-zephyr-1_6b-q4f32_1-MLC", display_name: "StableLM", provider: "Hugging Face", - family: "StableLM 2", + family: ModelFamily.STABLE_LM, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -837,7 +849,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "stablelm-2-zephyr-1_6b-q4f16_1-MLC-1k", display_name: "StableLM", provider: "Hugging Face", - family: "StableLM 2", + family: ModelFamily.STABLE_LM, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -849,7 +861,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "stablelm-2-zephyr-1_6b-q4f32_1-MLC-1k", display_name: "StableLM", provider: "Hugging Face", - family: "StableLM 2", + family: ModelFamily.STABLE_LM, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -861,7 +873,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "RedPajama-INCITE-Chat-3B-v1-q4f16_1-MLC", display_name: "RedPajama", provider: "Together", - family: "RedPajama", + family: ModelFamily.REDPAJAMA, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -871,7 +883,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "RedPajama-INCITE-Chat-3B-v1-q4f32_1-MLC", display_name: "RedPajama", provider: "Together", - family: "RedPajama", + family: ModelFamily.REDPAJAMA, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -881,7 +893,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "RedPajama-INCITE-Chat-3B-v1-q4f16_1-MLC-1k", display_name: "RedPajama", provider: "Together", - family: "RedPajama", + family: ModelFamily.REDPAJAMA, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -891,7 +903,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "RedPajama-INCITE-Chat-3B-v1-q4f32_1-MLC-1k", display_name: "RedPajama", provider: "Together", - family: "RedPajama", + family: ModelFamily.REDPAJAMA, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -901,7 +913,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "TinyLlama-1.1B-Chat-v1.0-q4f16_1-MLC", display_name: "TinyLlama", provider: "Zhang Peiyuan", - family: "TinyLlama", + family: ModelFamily.LLAMA, recommended_config: { temperature: 1, presence_penalty: 0, @@ -913,7 +925,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "TinyLlama-1.1B-Chat-v1.0-q4f32_1-MLC", display_name: "TinyLlama", provider: "Zhang Peiyuan", - family: "TinyLlama", + family: ModelFamily.LLAMA, recommended_config: { temperature: 1, presence_penalty: 0, @@ -925,7 +937,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "TinyLlama-1.1B-Chat-v1.0-q4f16_1-MLC-1k", display_name: "TinyLlama", provider: "Zhang Peiyuan", - family: "TinyLlama", + family: ModelFamily.LLAMA, recommended_config: { temperature: 1, presence_penalty: 0, @@ -937,7 +949,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "TinyLlama-1.1B-Chat-v1.0-q4f32_1-MLC-1k", display_name: "TinyLlama", provider: "Zhang Peiyuan", - family: "TinyLlama", + family: ModelFamily.LLAMA, recommended_config: { temperature: 1, presence_penalty: 0, @@ -949,7 +961,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3.1-70B-Instruct-q3f16_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3.1", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -961,7 +973,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-0.5B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -973,7 +985,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-0.5B-Instruct-q0f16-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -985,7 +997,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-0.5B-Instruct-q0f32-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -997,7 +1009,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-1.5B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -1009,7 +1021,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-1.5B-Instruct-q4f32_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -1021,7 +1033,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-7B-Instruct-q4f16_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -1033,7 +1045,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Qwen2-7B-Instruct-q4f32_1-MLC", display_name: "Qwen", provider: "Alibaba", - family: "Qwen 2", + family: ModelFamily.QWEN, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -1045,7 +1057,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3-8B-Instruct-q4f32_1-MLC-1k", display_name: "Llama", provider: "Meta", - family: "Llama 3", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -1057,7 +1069,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3-8B-Instruct-q4f16_1-MLC-1k", display_name: "Llama", provider: "Meta", - family: "Llama 3", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -1069,7 +1081,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3-8B-Instruct-q4f32_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -1081,7 +1093,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3-8B-Instruct-q4f16_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, presence_penalty: 0, @@ -1093,7 +1105,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-3-70B-Instruct-q3f16_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 3", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -1106,7 +1118,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Phi-3-mini-4k-instruct-q4f16_1-MLC", display_name: "Phi 3", provider: "Microsoft", - family: "Phi 3 Mini Instruct", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -1118,7 +1130,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Phi-3-mini-4k-instruct-q4f32_1-MLC", display_name: "Phi 3", provider: "Microsoft", - family: "Phi 3 Mini Instruct", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -1130,7 +1142,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Phi-3-mini-4k-instruct-q4f16_1-MLC-1k", display_name: "Phi 3", provider: "Microsoft", - family: "Phi 3 Mini Instruct", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -1142,7 +1154,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Phi-3-mini-4k-instruct-q4f32_1-MLC-1k", display_name: "Phi 3", provider: "Microsoft", - family: "Phi 3 Mini Instruct", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, presence_penalty: 0, @@ -1154,7 +1166,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-2-7b-chat-hf-q4f32_1-MLC-1k", display_name: "Llama", provider: "Meta", - family: "Llama 2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, top_p: 0.9, @@ -1164,7 +1176,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-2-7b-chat-hf-q4f16_1-MLC-1k", display_name: "Llama", provider: "Meta", - family: "Llama 2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, top_p: 0.9, @@ -1174,7 +1186,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-2-7b-chat-hf-q4f32_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, top_p: 0.9, @@ -1184,7 +1196,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-2-7b-chat-hf-q4f16_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, top_p: 0.9, @@ -1194,7 +1206,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "Llama-2-13b-chat-hf-q4f16_1-MLC", display_name: "Llama", provider: "Meta", - family: "Llama 2", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.6, top_p: 0.9, @@ -1204,7 +1216,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "phi-2-q4f16_1-MLC", display_name: "Phi", provider: "Microsoft", - family: "Phi 2", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1214,7 +1226,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "phi-2-q4f32_1-MLC", display_name: "Phi", provider: "Microsoft", - family: "Phi 2", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1224,7 +1236,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "phi-2-q4f16_1-MLC-1k", display_name: "Phi", provider: "Microsoft", - family: "Phi 2", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1234,7 +1246,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "phi-2-q4f32_1-MLC-1k", display_name: "Phi", provider: "Microsoft", - family: "Phi 2", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1244,7 +1256,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "phi-1_5-q4f16_1-MLC", display_name: "Phi", provider: "Microsoft", - family: "Phi 1.5", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1254,7 +1266,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "phi-1_5-q4f32_1-MLC", display_name: "Phi", provider: "Microsoft", - family: "Phi 1.5", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1264,7 +1276,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "phi-1_5-q4f16_1-MLC-1k", display_name: "Phi", provider: "Microsoft", - family: "Phi 1.5", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1274,7 +1286,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "phi-1_5-q4f32_1-MLC-1k", display_name: "Phi", provider: "Microsoft", - family: "Phi 1.5", + family: ModelFamily.PHI, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1284,7 +1296,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "TinyLlama-1.1B-Chat-v0.4-q4f16_1-MLC", display_name: "TinyLlama", provider: "Zhang Peiyuan", - family: "TinyLlama", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1294,7 +1306,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "TinyLlama-1.1B-Chat-v0.4-q4f32_1-MLC", display_name: "TinyLlama", provider: "Zhang Peiyuan", - family: "TinyLlama", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1304,7 +1316,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "TinyLlama-1.1B-Chat-v0.4-q4f16_1-MLC-1k", display_name: "TinyLlama", provider: "Zhang Peiyuan", - family: "TinyLlama", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.7, top_p: 0.95, @@ -1314,7 +1326,7 @@ const DEFAULT_MODEL_BASES: ModelRecord[] = [ name: "TinyLlama-1.1B-Chat-v0.4-q4f32_1-MLC-1k", display_name: "TinyLlama", provider: "Zhang Peiyuan", - family: "TinyLlama", + family: ModelFamily.LLAMA, recommended_config: { temperature: 0.7, top_p: 0.95, diff --git a/app/icons/google.svg b/app/icons/google.svg new file mode 100644 index 00000000..d8dc080f --- /dev/null +++ b/app/icons/google.svg @@ -0,0 +1,21 @@ + + + + + + diff --git a/app/icons/meta.svg b/app/icons/meta.svg new file mode 100644 index 00000000..0124b8fa --- /dev/null +++ b/app/icons/meta.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + diff --git a/app/icons/microsoft.svg b/app/icons/microsoft.svg new file mode 100644 index 00000000..5c841b49 --- /dev/null +++ b/app/icons/microsoft.svg @@ -0,0 +1,10 @@ + + + + + + diff --git a/app/icons/mistral.svg b/app/icons/mistral.svg new file mode 100644 index 00000000..82e252aa --- /dev/null +++ b/app/icons/mistral.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/icons/snowflake.svg b/app/icons/snowflake.svg new file mode 100644 index 00000000..de2ee949 --- /dev/null +++ b/app/icons/snowflake.svg @@ -0,0 +1,18 @@ + + Snowflake Logo + + + + + + + + +; diff --git a/app/icons/stablelm.svg b/app/icons/stablelm.svg new file mode 100644 index 00000000..a92c235f --- /dev/null +++ b/app/icons/stablelm.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 05a220ca..87e9ba07 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -314,6 +314,10 @@ const cn = { Settings: "检测到链接中包含了预制设置,是否自动填入?", }, + ModelSelect: { + Title: "选择模型", + SearchPlaceholder: "搜索一个模型……", + }, UI: { Confirm: "确认", Cancel: "取消", diff --git a/app/locales/en.ts b/app/locales/en.ts index b8368706..e1f295a5 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -347,7 +347,10 @@ const en = { NotShow: "Never Show Again", ConfirmNoShow: "Confirm to disable? You can enable it in settings later.", }, - + ModelSelect: { + Title: "Model Selection", + SearchPlaceholder: "Search model...", + }, UI: { Confirm: "Confirm", Cancel: "Cancel", diff --git a/app/store/chat.ts b/app/store/chat.ts index 02be69e1..2fb9ec1d 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -552,7 +552,7 @@ export const useChatStore = createPersistStore( const historyMsgLength = countMessages(toBeSummarizedMsgs); - if (historyMsgLength > modelConfig?.max_tokens ?? 4000) { + if (historyMsgLength > (modelConfig?.max_tokens ?? 4000)) { const n = toBeSummarizedMsgs.length; toBeSummarizedMsgs = toBeSummarizedMsgs.slice( Math.max(0, n - config.historyMessageCount), diff --git a/app/styles/globals.scss b/app/styles/globals.scss index 75b31da4..1ba2ce27 100644 --- a/app/styles/globals.scss +++ b/app/styles/globals.scss @@ -7,7 +7,7 @@ /* color */ --white: white; --black: rgb(48, 48, 48); - --gray: rgb(250, 250, 250); + --gray: rgb(240, 240, 240); --light-gray: rgb(120, 120, 120); --primary: rgb(90, 96, 135); --second: rgb(228, 229, 241); diff --git a/app/utils/model.ts b/app/utils/model.ts deleted file mode 100644 index 05a2da66..00000000 --- a/app/utils/model.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { ModelRecord } from "../client/api"; - -export function collectModelTable( - models: readonly ModelRecord[], - customModels: string, -) { - const modelTable: Record< - string, - { - name: string; - display_name: string; - provider?: ModelRecord["provider"]; // Marked as optional - isDefault?: boolean; - } - > = {}; - - // default models - models.forEach((m) => { - modelTable[m.name] = { - ...m, - display_name: m.name, // 'provider' is copied over if it exists - }; - }); - - // server custom models - customModels - .split(",") - .filter((v) => !!v && v.length > 0) - .forEach((m) => { - const available = !m.startsWith("-"); - const nameConfig = - m.startsWith("+") || m.startsWith("-") ? m.slice(1) : m; - const [name, display_name] = nameConfig.split("="); - - modelTable[name] = { - name, - display_name: display_name || name, - provider: modelTable[name]?.provider ?? "", // Use optional chaining - }; - }); - - return modelTable; -} - -/** - * Generate full model table. - */ -export function collectModels( - models: readonly ModelRecord[], - customModels: string, -) { - const modelTable = collectModelTable(models, customModels); - const allModels = Object.values(modelTable); - - return allModels; -} diff --git a/app/utils/model.tsx b/app/utils/model.tsx new file mode 100644 index 00000000..4ebb3567 --- /dev/null +++ b/app/utils/model.tsx @@ -0,0 +1,90 @@ +import React from "react"; +import MetaIcon from "@/app/icons/meta.svg"; +import MicrosoftIcon from "@/app/icons/microsoft.svg"; +import MistralIcon from "@/app/icons/mistral.svg"; +import GoogleIcon from "@/app/icons/google.svg"; +import StablelmICon from "@/app/icons/stablelm.svg"; +import { ModelRecord } from "../client/api"; +import { ModelFamily } from "../constant"; +import { Shirt, WandSparkles } from "lucide-react"; + +export function collectModelTable( + models: readonly ModelRecord[], + customModels: string, +) { + const modelTable: Record< + string, + { + name: string; + display_name: string; + provider?: ModelRecord["provider"]; // Marked as optional + isDefault?: boolean; + } + > = {}; + + // default models + models.forEach((m) => { + modelTable[m.name] = { + ...m, + display_name: m.name, // 'provider' is copied over if it exists + }; + }); + + // server custom models + customModels + .split(",") + .filter((v) => !!v && v.length > 0) + .forEach((m) => { + const available = !m.startsWith("-"); + const nameConfig = + m.startsWith("+") || m.startsWith("-") ? m.slice(1) : m; + const [name, display_name] = nameConfig.split("="); + + modelTable[name] = { + name, + display_name: display_name || name, + provider: modelTable[name]?.provider ?? "", // Use optional chaining + }; + }); + + return modelTable; +} + +/** + * Generate full model table. + */ +export function collectModels( + models: readonly ModelRecord[], + customModels: string, +) { + const modelTable = collectModelTable(models, customModels); + const allModels = Object.values(modelTable); + + return allModels; +} + +export interface ModelDetails { + family: ModelFamily; + name: string; + icon?: React.ComponentType>; +} + +export const modelDetailsList: ModelDetails[] = [ + { family: ModelFamily.LLAMA, name: "Llama", icon: MetaIcon }, + { family: ModelFamily.PHI, name: "Phi", icon: MicrosoftIcon }, + { family: ModelFamily.MISTRAL, name: "Mistral", icon: MistralIcon }, + { family: ModelFamily.GEMMA, name: "Gemma", icon: GoogleIcon }, + { + family: ModelFamily.QWEN, + name: "Qwen", + icon: (...props) => Qwen Logo, + }, + { + family: ModelFamily.SMOL_LM, + name: "SmolLM", + icon: (...props) => SmolLM Logo, + }, + { family: ModelFamily.WIZARD_MATH, name: "Wizard Math", icon: WandSparkles }, + { family: ModelFamily.STABLE_LM, name: "StableLM", icon: StablelmICon }, + { family: ModelFamily.REDPAJAMA, name: "RedPajama", icon: Shirt }, +]; diff --git a/package.json b/package.json index 615d462d..e87da62b 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "fuse.js": "^7.0.0", "html-to-image": "^1.11.11", "loglevel": "^1.9.1", + "lucide-react": "^0.454.0", "mermaid": "^10.6.1", "nanoid": "^5.0.3", "next": "^13.4.9", diff --git a/public/qwen.webp b/public/qwen.webp new file mode 100644 index 00000000..05cbcdde Binary files /dev/null and b/public/qwen.webp differ diff --git a/public/smollm.png b/public/smollm.png new file mode 100644 index 00000000..9c259348 Binary files /dev/null and b/public/smollm.png differ diff --git a/yarn.lock b/yarn.lock index 409eb1ff..6626eca0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4813,6 +4813,11 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" +lucide-react@^0.454.0: + version "0.454.0" + resolved "https://registry.yarnpkg.com/lucide-react/-/lucide-react-0.454.0.tgz#a81b9c482018720f07ead0503ae502d94d528444" + integrity sha512-hw7zMDwykCLnEzgncEEjHeA6+45aeEzRYuKHuyRSOPkhko+J3ySGjGIzu+mmMfDFG1vazHepMaYFYHbTFAZAAQ== + magic-string@^0.25.0, magic-string@^0.25.7: version "0.25.9" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c"