Moonshot: Pull vision flag from model data Fixes #5068
| @@ -623,6 +623,7 @@ jQuery(async function () { | ||
| 623 | 623 | await processEndpoint('electronhub', '/api/backends/chat-completions/multimodal-models/electronhub'); |
| 624 | 624 | await processEndpoint('mistral', '/api/backends/chat-completions/multimodal-models/mistral'); |
| 625 | 625 | await processEndpoint('xai', '/api/backends/chat-completions/multimodal-models/xai'); |
| 626 | + await processEndpoint('moonshot', '/api/backends/chat-completions/multimodal-models/moonshot'); | |
| 626 | 627 | } |
| 627 | 628 | |
| 628 | 629 | await addSettings(); |
| @@ -49,13 +49,10 @@ | ||
| 49 | 49 | </div> |
| 50 | 50 | </label> |
| 51 | 51 | <select id="caption_multimodal_model" class="flex1 text_pole"> |
| 52 | 52 | <!-- AI/ML API, OpenRouter, Pollinations, NanoGPT, Mistral, xAI, Moonshot are added externally by JavaScript --> |
| 53 | 53 | <option data-type="cohere" value="c4ai-aya-vision-8b">c4ai-aya-vision-8b</option> |
| 54 | 54 | <option data-type="cohere" value="c4ai-aya-vision-32b">c4ai-aya-vision-32b</option> |
| 55 | 55 | <option data-type="cohere" value="command-a-vision-07-2025">command-a-vision-07-2025</option> |
| 56 | - <option data-type="moonshot" value="moonshot-v1-8k-vision-preview">moonshot-v1-8k-vision-preview</option> | |
| 57 | - <option data-type="moonshot" value="moonshot-v1-32k-vision-preview">moonshot-v1-32k-vision-preview</option> | |
| 58 | - <option data-type="moonshot" value="moonshot-v1-128k-vision-preview">moonshot-v1-128k-vision-preview</option> | |
| 59 | 56 | <option data-type="openai" value="gpt-5.2">gpt-5.2</option> |
| 60 | 57 | <option data-type="openai" value="gpt-5.2-2025-12-11">gpt-5.2-2025-12-11</option> |
| 61 | 58 | <option data-type="openai" value="gpt-5.2-chat-latest">gpt-5.2-chat-latest</option> |
| @@ -4909,8 +4909,13 @@ function getMoonshotMaxContext(model, isUnlocked) { | ||
| 4909 | 4909 | 'moonshot-v1-32k-vision-preview': max_32k, |
| 4910 | 4910 | 'moonshot-v1-128k-vision-preview': max_128k, |
| 4911 | 4911 | 'kimi-k2-0711-preview': max_32k, |
| 4912 | 4912 | 'kimi-latest': max_32kmax_256k, |
| 4913 | 4913 | 'kimi-thinking-preview': max_32k, |
| 4914 | + 'kimi-k2.5': max_256k, | |
| 4915 | + 'kimi-k2-0905-preview': max_256k, | |
| 4916 | + 'kimi-k2-turbo-preview': max_256k, | |
| 4917 | + 'kimi-k2-thinking': max_256k, | |
| 4918 | + 'kimi-k2-thinking-turbo': max_256k, | |
| 4914 | 4919 | }; |
| 4915 | 4920 | |
| 4916 | 4921 | // Return context size if model found, otherwise default to 32k |
| @@ -5837,6 +5842,8 @@ export function isImageInliningSupported() { | ||
| 5837 | 5842 | 'moonshot-v1-8k-vision-preview', |
| 5838 | 5843 | 'moonshot-v1-32k-vision-preview', |
| 5839 | 5844 | 'moonshot-v1-128k-vision-preview', |
| 5845 | + 'kimi-k2.5', | |
| 5846 | + 'kimi-latest', | |
| 5840 | 5847 | // Z.AI (GLM) |
| 5841 | 5848 | 'glm-4.5v', |
| 5842 | 5849 | 'glm-4.6v', |
| @@ -5888,7 +5895,7 @@ export function isImageInliningSupported() { | ||
| 5888 | 5895 | case chat_completion_sources.COMETAPI: |
| 5889 | 5896 | return true; |
| 5890 | 5897 | case chat_completion_sources.MOONSHOT: |
| 5891 | - return visionSupportedModels.some(model => oai_settings.moonshot_model.includes(model)); | |
| 5898 | + return (Array.isArray(model_list) && model_list.find(m => m.id === oai_settings.moonshot_model)?.supports_image_in); | |
| 5892 | 5899 | case chat_completion_sources.NANOGPT: |
| 5893 | 5900 | return (Array.isArray(model_list) && model_list.find(m => m.id === oai_settings.nanogpt_model)?.capabilities?.vision); |
| 5894 | 5901 | case chat_completion_sources.ZAI: |
| @@ -2615,6 +2615,35 @@ multimodalModels.post('/xai', async (req, res) => { | ||
| 2615 | 2615 | } |
| 2616 | 2616 | }); |
| 2617 | 2617 | |
| 2618 | +multimodalModels.post('/moonshot', async (req, res) => { | |
| 2619 | + try { | |
| 2620 | + const key = readSecret(req.user.directories, SECRET_KEYS.MOONSHOT); | |
| 2621 | + | |
| 2622 | + if (!key) { | |
| 2623 | + return res.json([]); | |
| 2624 | + } | |
| 2625 | + | |
| 2626 | + const response = await fetch('https://api.moonshot.ai/v1/models', { | |
| 2627 | + headers: { | |
| 2628 | + 'Authorization': `Bearer ${key}`, | |
| 2629 | + }, | |
| 2630 | + }); | |
| 2631 | + | |
| 2632 | + if (!response.ok) { | |
| 2633 | + return res.json([]); | |
| 2634 | + } | |
| 2635 | + | |
| 2636 | + /** @type {any} */ | |
| 2637 | + const data = await response.json(); | |
| 2638 | + | |
| 2639 | + const multimodalModels = data.data.filter(m => m.supports_image_in).map(m => m.id); | |
| 2640 | + return res.json(multimodalModels); | |
| 2641 | + } catch (error) { | |
| 2642 | + console.error(error); | |
| 2643 | + return res.sendStatus(500); | |
| 2644 | + } | |
| 2645 | +}); | |
| 2646 | + | |
| 2618 | 2647 | router.use('/multimodal-models', multimodalModels); |
| 2619 | 2648 | |
| 2620 | 2649 | router.post('/process', async function (request, response) { |