Files
oh-my-opencode/src/plugin-state.ts
T

31 lines
711 B
TypeScript
Raw Normal View History

export interface ModelCacheState {
modelContextLimitsCache: Map<string, number>;
anthropicContext1MEnabled: boolean;
}
export function createModelCacheState(): ModelCacheState {
return {
modelContextLimitsCache: new Map<string, number>(),
anthropicContext1MEnabled: false,
};
}
export function getModelLimit(
state: ModelCacheState,
providerID: string,
modelID: string
): number | undefined {
const key = `${providerID}/${modelID}`;
const cached = state.modelContextLimitsCache.get(key);
if (cached) return cached;
if (
providerID === "anthropic" &&
state.anthropicContext1MEnabled &&
modelID.includes("sonnet")
) {
return 1_000_000;
}
return undefined;
}