diff --git a/src/packages/frontend/frame-editors/llm/model-switch.tsx b/src/packages/frontend/frame-editors/llm/model-switch.tsx index eda078644b..6298d6c002 100644 --- a/src/packages/frontend/frame-editors/llm/model-switch.tsx +++ b/src/packages/frontend/frame-editors/llm/model-switch.tsx @@ -6,6 +6,7 @@ import { CSS, redux, useTypedRedux } from "@cocalc/frontend/app-framework"; import { LanguageModelVendorAvatar } from "@cocalc/frontend/components/language-model-icon"; import { DEFAULT_MODEL, + LLM_DESCR, LLM_USERNAMES, LanguageModel, MISTRAL_MODELS, @@ -90,7 +91,7 @@ export default function ModelSwitch({ ); const tooltip = ( <> - {model}: {title} + {model} – {title} ); const display = ( @@ -108,42 +109,16 @@ export default function ModelSwitch({ function appendOpenAI(ret: NonNullable) { if (!showOpenAI) return null; - makeLLMOption( - ret, - "gpt-3.5-turbo", - "OpenAI's fastest model, great for most everyday tasks (4k token context)", - ); - makeLLMOption( - ret, - "gpt-3.5-turbo-16k", - `Same as ${modelToName( - "gpt-3.5-turbo", - )} but with much larger context size (16k token context)`, - ); - makeLLMOption( - ret, - "gpt-4", - "GPT-4 can follow complex instructions in natural language and solve difficult problems with accuracy. (8k token context)", - ); - makeLLMOption( - ret, - "gpt-4-turbo-preview", - "GPT-4 Turbo is more powerful, has fresher knowledge and offered at a lower price than GPT-4. (128k token context)", - ); + makeLLMOption(ret, "gpt-3.5-turbo", LLM_DESCR["gpt-3.5-turbo"]); + makeLLMOption(ret, "gpt-3.5-turbo-16k", LLM_DESCR["gpt-3.5-turbo-16k"]); + makeLLMOption(ret, "gpt-4", LLM_DESCR["gpt-4"]); + makeLLMOption(ret, "gpt-4-turbo-preview", LLM_DESCR["gpt-4-turbo-preview"]); } function appendGoogle(ret: NonNullable) { if (!showGoogle) return null; - return ( - <> - {makeLLMOption( - ret, - GOOGLE_GEMINI, - `Google's Gemini Pro Generative AI model (30k token context)`, - )} - - ); + return <>{makeLLMOption(ret, GOOGLE_GEMINI, LLM_DESCR[GOOGLE_GEMINI])}; } function appendMistral(ret: NonNullable) { @@ -151,21 +126,9 @@ export default function ModelSwitch({ return ( <> - {makeLLMOption( - ret, - MISTRAL_MODELS[0], - "Fast, simple queries, short answers, less capabilities", - )} - {makeLLMOption( - ret, - MISTRAL_MODELS[1], - "Intermediate tasks, summarizing, generating documents, etc.", - )} - {makeLLMOption( - ret, - MISTRAL_MODELS[2], - "Slowest, most powerful, large reasoning capabilities", - )} + {makeLLMOption(ret, MISTRAL_MODELS[0], LLM_DESCR[MISTRAL_MODELS[0]])} + {makeLLMOption(ret, MISTRAL_MODELS[1], LLM_DESCR[MISTRAL_MODELS[1]])} + {makeLLMOption(ret, MISTRAL_MODELS[2], LLM_DESCR[MISTRAL_MODELS[2]])} ); } @@ -178,7 +141,8 @@ export default function ModelSwitch({ const ollamaModel = toOllamaModel(key); const text = ( <> - {display} {getPrice(ollamaModel)}: {desc ?? "Ollama"} + {display} {getPrice(ollamaModel)} –{" "} + {desc ?? "Ollama"} ); ret.push({ diff --git a/src/packages/util/db-schema/llm-utils.ts b/src/packages/util/db-schema/llm-utils.ts index fbc76d150d..973a84405e 100644 --- a/src/packages/util/db-schema/llm-utils.ts +++ b/src/packages/util/db-schema/llm-utils.ts @@ -263,10 +263,7 @@ export function fromMistralService(model: MistralService) { return model.slice(MISTRAL_PREFIX.length); } -// Map from psuedo account_id to what should be displayed to user. -// This is used in various places in the frontend. -// Google PaLM: https://cloud.google.com/vertex-ai/docs/generative-ai/pricing -export const LLM_USERNAMES: { +type LLM2String = { [key in | (typeof USER_SELECTABLE_LANGUAGE_MODELS)[number] | "chatgpt" // some additional ones, backwards compatibility @@ -275,7 +272,12 @@ export const LLM_USERNAMES: { | "gpt-4-32k" | "text-bison-001" | "chat-bison-001"]: string; -} = { +}; + +// Map from psuedo account_id to what should be displayed to user. +// This is used in various places in the frontend. +// Google PaLM: https://cloud.google.com/vertex-ai/docs/generative-ai/pricing +export const LLM_USERNAMES: LLM2String = { chatgpt: "GPT-3.5", chatgpt3: "GPT-3.5", chatgpt4: "GPT-4", @@ -292,6 +294,31 @@ export const LLM_USERNAMES: { "mistral-large-latest": "Mistral AI Large", } as const; +// similar to the above, we map to short user-visible description texts +// this comes next to the name, hence you do not have to mention the name +export const LLM_DESCR: LLM2String = { + chatgpt: "Fast, great for everyday tasks. (OpenAI, 4k token context)", + chatgpt3: "Fast, great for everyday tasks. (OpenAI, 4k token context)", + chatgpt4: + "Can follow complex instructions and solve difficult problems. (OpenAI, 8k token context)", + "gpt-4": + "Can follow complex instructions and solve difficult problems. (OpenAI, 8k token context)", + "gpt-4-32k": "", + "gpt-3.5-turbo": "Fast, great for everyday tasks. (OpenAI, 4k token context)", + "gpt-3.5-turbo-16k": `Same as ${LLM_USERNAMES["gpt-3.5-turbo"]} but with larger 16k token context`, + "gpt-4-turbo-preview": + "More powerful, fresher knowledge, and lower price than GPT-4. (OpenAI, 128k token context)", + "text-bison-001": "", + "chat-bison-001": "", + "gemini-pro": "Google's Gemini Pro Generative AI model (30k token context)", + "mistral-small-latest": + "Fast, simple queries, short answers, less capabilities. (Mistral AI, 4k token context)", + "mistral-medium-latest": + "Intermediate tasks, summarizing, generating documents, etc. (Mistral AI, 4k token context)", + "mistral-large-latest": + "Most powerful, large reasoning capabilities, but slower. (Mistral AI, 4k token context)", +} as const; + export function isFreeModel(model: unknown) { if (isOllamaLLM(model)) return true; if (isMistralModel(model)) { diff --git a/src/packages/util/db-schema/site-settings-extras.ts b/src/packages/util/db-schema/site-settings-extras.ts index 0703847a93..edc8a5a9ce 100644 --- a/src/packages/util/db-schema/site-settings-extras.ts +++ b/src/packages/util/db-schema/site-settings-extras.ts @@ -282,7 +282,7 @@ export const EXTRAS: SettingsExtras = { }, ollama_configuration: { name: "Ollama Configuration", - desc: 'Configure Ollama endpoints. e.g. Ollama has "gemma" installed and runs at localhost:11434: `{"gemma" : {"baseUrl": "http://localhost:11434/" , cocalc: {display: "Gemma", desc: "Google\'s Gemma Model"}}', + desc: 'Configure Ollama endpoints. e.g. Ollama has "gemma" installed and is available at localhost:11434: `{"gemma" : {"baseUrl": "http://localhost:11434/" , cocalc: {display: "Gemma", desc: "Google\'s Gemma Model"}}', default: "", multiline: 5, show: ollama_enabled,