25 lines · 904 B · TypeScript
RawDownload
import type { ModelSelection, ProviderInstanceId } from "@t3tools/contracts";import { getTriggerDisplayModelName, type ModelEsque } from "./providerIconUtils"; export function resolveContextWindowModelDisplayName(  selection: ModelSelection | null | undefined,  modelOptionsByInstance: ReadonlyMap<ProviderInstanceId, ReadonlyArray<ModelEsque>>,): string | null {  if (!selection) {    return null;  }   const selectedModel = modelOptionsByInstance    .get(selection.instanceId)    ?.find((model) => model.slug === selection.model);   return selectedModel ? getTriggerDisplayModelName(selectedModel) : selection.model;} export function formatContextWindowCompactionMessage(  modelDisplayName: string | null | undefined,): string {  return modelDisplayName    ? `Context for ${modelDisplayName} compacts automatically when needed.`    : "Context compacts automatically when needed.";}