Path: blob/master/src/packages/frontend/components/llm-name.tsx
1503 views
import { useTypedRedux } from "@cocalc/frontend/app-framework";1import { modelToName } from "@cocalc/frontend/frame-editors/llm/llm-selector";2import {3LanguageModel,4fromCustomOpenAIModel,5fromOllamaModel,6isCustomOpenAI,7isLanguageModel,8isOllamaLLM,9} from "@cocalc/util/db-schema/llm-utils";10import { LanguageModelVendorAvatar } from "./language-model-icon";1112export function LLMModelName(13props: Readonly<{ model: LanguageModel; size?: number }>,14) {15const { model, size } = props;1617const ollama = useTypedRedux("customize", "ollama");18const custom_openai = useTypedRedux("customize", "custom_openai");1920function renderTitle() {21if (isOllamaLLM(model)) {22const om = ollama?.get(fromOllamaModel(model));23if (om) {24return om.get("display") ?? `Ollama ${model}`;25}26}2728if (isCustomOpenAI(model)) {29const coi = custom_openai?.get(fromCustomOpenAIModel(model));30if (coi) {31return coi.get("display") ?? `OpenAI (custom) ${model}`;32}33}3435if (isLanguageModel(model)) {36return modelToName(model);37}3839return model;40}4142return (43<>44<LanguageModelVendorAvatar45model={model}46size={size}47style={{ marginRight: 0 }}48/>{" "}49{renderTitle()}50</>51);52}535455