Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ContextWindowMeter.logic.ts

25 lines904 Bytes

1import type { ModelSelection, ProviderInstanceId } from "@t3tools/contracts";
2import { getTriggerDisplayModelName, type ModelEsque } from "./providerIconUtils";
3​
4export function resolveContextWindowModelDisplayName(
5 selection: ModelSelection | null | undefined,
6 modelOptionsByInstance: ReadonlyMap<ProviderInstanceId, ReadonlyArray<ModelEsque>>,
7): string | null {
8 if (!selection) {
9 return null;
10 }
11​
12 const selectedModel = modelOptionsByInstance
13 .get(selection.instanceId)
14 ?.find((model) => model.slug === selection.model);
15​
16 return selectedModel ? getTriggerDisplayModelName(selectedModel) : selection.model;
18​
19export function formatContextWindowCompactionMessage(
20 modelDisplayName: string | null | undefined,
21): string {
22 return modelDisplayName
23 ? `Context for ${modelDisplayName} compacts automatically when needed.`
24 : "Context compacts automatically when needed.";