MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / catalogModelToCapability

Function catalogModelToCapability

packages/kosong/src/catalog.ts:120–141  ·  view source on GitHub ↗
(model: CatalogModelEntry)

Source from the content-addressed store, hash-verified

118
119/** Normalizes one catalog model entry into a {@link CatalogModel}; skips invalid entries. */
120export function catalogModelToCapability(model: CatalogModelEntry): CatalogModel | undefined {
121 if (typeof model.id !== 'string' || model.id.length === 0) return undefined;
122 const context = model.limit?.context;
123 if (typeof context !== 'number' || !Number.isInteger(context) || context <= 0) return undefined;
124 if (!isUsableChatModel(model)) return undefined;
125 const inputs = model.modalities?.input ?? [];
126 const output = model.limit?.output;
127 return {
128 id: model.id,
129 name: typeof model.name === 'string' && model.name.length > 0 ? model.name : undefined,
130 maxOutputSize: typeof output === 'number' && output > 0 ? output : undefined,
131 reasoningKey: catalogReasoningKey(model.interleaved),
132 capability: {
133 image_in: inputs.includes('image'),
134 video_in: inputs.includes('video'),
135 audio_in: inputs.includes('audio'),
136 thinking: Boolean(model.reasoning),
137 tool_use: model.tool_call ?? true,
138 max_context_tokens: context,
139 },
140 };
141}
142
143function catalogReasoningKey(interleaved: CatalogModelEntry['interleaved']): string | undefined {
144 // models.dev allows `interleaved: true` as "general support" — read it as

Callers 2

catalog.test.tsFile · 0.90
catalogProviderModelsFunction · 0.85

Calls 2

isUsableChatModelFunction · 0.85
catalogReasoningKeyFunction · 0.85

Tested by

no test coverage detected