UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

37 lines • 1.95 kB
const FAST_MODEL_SUFFIX = "-fast"; function requestModelId(registry, model) { return registry.getUpstreamModelId(model) ?? model.id; } function isCompatibleFastVariant(registry, baseModel, fastModel) { return (fastModel.provider === baseModel.provider && fastModel.api === baseModel.api && registry.getServiceTier(fastModel) === "priority" && requestModelId(registry, fastModel) === requestModelId(registry, baseModel)); } /** The base model a `-fast` catalog variant is served as (same provider, same request id, priority tier). */ export function findBaseModel(registry, fastModel) { if (!fastModel.id.endsWith(FAST_MODEL_SUFFIX)) return undefined; const baseModel = registry.find(fastModel.provider, fastModel.id.slice(0, -FAST_MODEL_SUFFIX.length)); return baseModel && isCompatibleFastVariant(registry, baseModel, fastModel) ? baseModel : undefined; } /** The `-fast` catalog variant of a base model, when the catalog pairs them. */ export function findFastModel(registry, baseModel) { if (baseModel.id.endsWith(FAST_MODEL_SUFFIX)) return undefined; const fastModel = registry.find(baseModel.provider, `${baseModel.id}${FAST_MODEL_SUFFIX}`); return fastModel && isCompatibleFastVariant(registry, baseModel, fastModel) ? fastModel : undefined; } /** `resolveChainKey`'s option naming the current model's `-fast` sibling, when the catalog has one. */ export function fastSiblingOption(registry, model) { const { getUpstreamModelId, getServiceTier } = registry; if (!getUpstreamModelId || !getServiceTier) return {}; const fastSibling = findFastModel({ find: (provider, id) => registry.find(provider, id), getUpstreamModelId: (m) => getUpstreamModelId.call(registry, m), getServiceTier: (m) => getServiceTier.call(registry, m), }, model); return fastSibling ? { fastSibling } : {}; } //# sourceMappingURL=fast-model-pair.js.map