'use strict'; const { getModelByKey } = require('../config'); function buildProfile(model) { const supportsThinking = model.modes === 'thinking' || model.modes === 'fast+thinking'; return { key: model.key, name: model.name, base_url: model.base_url, api_key: model.api_key, model_id: model.model_id || model.name, modes: model.modes, multimodal: model.multimodal, max_output: Number.isFinite(model.max_output) ? model.max_output : null, max_context: Number.isFinite(model.max_context) ? model.max_context : null, supports_thinking: supportsThinking, thinking_params: supportsThinking ? { fast: { thinking: { type: 'disabled' } }, thinking: { thinking: { type: 'enabled' } }, } : { fast: {}, thinking: {} }, }; } function getModelProfile(config, modelKey) { const model = getModelByKey(config, modelKey); if (!model || !model.valid) { throw new Error(`模型配置无效或不存在: ${modelKey || ''}`); } return buildProfile(model); } module.exports = { getModelProfile };