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

Function toModelInfo

packages/oauth/src/open-platform.ts:47–76  ·  view source on GitHub ↗
(item: unknown)

Source from the content-addressed store, hash-verified

45}
46
47function toModelInfo(item: unknown): ManagedKimiCodeModelInfo | undefined {
48 if (!isRecord(item) || typeof item['id'] !== 'string' || item['id'].length === 0) {
49 return undefined;
50 }
51 const contextLength = Number(item['context_length']);
52 if (!Number.isInteger(contextLength) || contextLength <= 0) {
53 throw new Error(`Model "${item['id']}" must include a positive context_length.`);
54 }
55 const displayName = item['display_name'];
56 const normalizedDisplayName =
57 typeof displayName === 'string' && displayName.length > 0 ? displayName : undefined;
58 const supportsToolUse = Object.hasOwn(item, 'supports_tool_use')
59 ? Boolean(item['supports_tool_use'])
60 : true;
61 // Effort levels come from the nested `think_efforts` object
62 // ({ support, valid_efforts, default_effort }) returned by /models.
63 const thinkEfforts = parseThinkEfforts(item['think_efforts']);
64 return {
65 id: item['id'],
66 contextLength,
67 supportsReasoning: Boolean(item['supports_reasoning']),
68 supportsImageIn: Boolean(item['supports_image_in']),
69 supportsVideoIn: Boolean(item['supports_video_in']),
70 supportsToolUse,
71 supportsThinkingType: parseSupportsThinkingType(item['supports_thinking_type']),
72 supportEfforts: thinkEfforts.supportEfforts,
73 defaultEffort: thinkEfforts.defaultEffort,
74 displayName: normalizedDisplayName,
75 };
76}
77
78export function capabilitiesForModel(model: ManagedKimiCodeModelInfo): string[] | undefined {
79 const caps = new Set<string>();

Callers 1

fetchOpenPlatformModelsFunction · 0.70

Calls 3

isRecordFunction · 0.90
parseThinkEffortsFunction · 0.90

Tested by

no test coverage detected