Moonshot: Map "Request reasoning" to thinking type Fixes #5072
| @@ -2105,7 +2105,7 @@ | ||
| 2105 | 2105 | <span data-i18n="Allows the model to return its thinking process."> |
| 2106 | 2106 | Allows the model to return its thinking process. |
| 2107 | 2107 | </span> |
| 2108 | 2108 | <strong data-i18n="This setting affects visibility only." data-source-mode="except" data-source="zai,moonshot"> |
| 2109 | 2109 | This setting affects visibility only. |
| 2110 | 2110 | </strong> |
| 2111 | 2111 | </div> |
| @@ -2736,6 +2736,17 @@ export async function createGenerationParameters(settings, model, type, messages | ||
| 2736 | 2736 | generate_data.top_a = Number(settings.top_a_openai); |
| 2737 | 2737 | } |
| 2738 | 2738 | |
| 2739 | + // https://platform.moonshot.ai/docs/api/chat#public-service-address | |
| 2740 | + if (settings.chat_completion_source === chat_completion_sources.MOONSHOT) { | |
| 2741 | + // >Kimi API is fully compatible with OpenAI's API format | |
| 2742 | + if (/kimi-k2.5/.test(model)) { | |
| 2743 | + delete generate_data.temperature; | |
| 2744 | + delete generate_data.top_p; | |
| 2745 | + delete generate_data.frequency_penalty; | |
| 2746 | + delete generate_data.presence_penalty; | |
| 2747 | + } | |
| 2748 | + } | |
| 2749 | + | |
| 2739 | 2750 | if (seedSupportedSources.includes(settings.chat_completion_source) && settings.seed >= 0) { |
| 2740 | 2751 | generate_data.seed = settings.seed; |
| 2741 | 2752 | } |
| @@ -2262,7 +2262,11 @@ router.post('/generate', async function (request, response) { | ||
| 2262 | 2262 | apiUrl = new URL(request.body.reverse_proxy || API_MOONSHOT).toString(); |
| 2263 | 2263 | apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.MOONSHOT); |
| 2264 | 2264 | headers = {}; |
| 2265 | 2265 | bodyParams = {}; |
| 2266 | + thinking: { | |
| 2267 | + type: request.body.include_reasoning ? 'enabled' : 'disabled', | |
| 2268 | + }, | |
| 2269 | + }; | |
| 2266 | 2270 | request.body.json_schema |
| 2267 | 2271 | ? setJsonObjectFormat(bodyParams, request.body.messages, request.body.json_schema) |
| 2268 | 2272 | : addAssistantPrefix(request.body.messages, [], 'partial'); |