OpenRouter/MistralAI: Improve capability checks for tool calling and image inlining
| @@ -3677,6 +3677,7 @@ async function getStatusOpen() { | ||
| 3677 | 3677 | if (noValidateSources.includes(oai_settings.chat_completion_source)) { |
| 3678 | 3678 | let status = t`Key saved; press \"Test Message\" to verify.`; |
| 3679 | 3679 | setOnlineStatus(status); |
| 3680 | + updateFeatureSupportFlags(); | |
| 3680 | 3681 | return resultCheckStatus(); |
| 3681 | 3682 | } |
| 3682 | 3683 | |
| @@ -3748,6 +3749,7 @@ async function getStatusOpen() { | ||
| 3748 | 3749 | } |
| 3749 | 3750 | } |
| 3750 | 3751 | |
| 3752 | + updateFeatureSupportFlags(); | |
| 3751 | 3753 | return resultCheckStatus(); |
| 3752 | 3754 | } |
| 3753 | 3755 | |
| @@ -5427,11 +5429,11 @@ export function isImageInliningSupported() { | ||
| 5427 | 5429 | case chat_completion_sources.CLAUDE: |
| 5428 | 5430 | return visionSupportedModels.some(model => oai_settings.claude_model.includes(model)); |
| 5429 | 5431 | case chat_completion_sources.OPENROUTER: |
| 5430 | - return true; | |
| 5432 | + return (Array.isArray(model_list) && model_list.find(m => m.id === oai_settings.openrouter_model)?.architecture?.modality === 'text+image->text'); | |
| 5431 | 5433 | case chat_completion_sources.CUSTOM: |
| 5432 | 5434 | return true; |
| 5433 | 5435 | case chat_completion_sources.MISTRALAI: |
| 5434 | - return visionSupportedModels.some(model => oai_settings.mistralai_model.includes(model)); | |
| 5436 | + return (Array.isArray(model_list) && model_list.find(m => m.id === oai_settings.mistralai_model)?.capabilities?.vision); | |
| 5435 | 5437 | case chat_completion_sources.COHERE: |
| 5436 | 5438 | return visionSupportedModels.some(model => oai_settings.cohere_model.includes(model)); |
| 5437 | 5439 | case chat_completion_sources.XAI: |
| @@ -6036,6 +6038,7 @@ export function initOpenAI() { | ||
| 6036 | 6038 | |
| 6037 | 6039 | $('#openai_image_inlining').on('input', function () { |
| 6038 | 6040 | oai_settings.image_inlining = !!$(this).prop('checked'); |
| 6041 | + updateFeatureSupportFlags(); | |
| 6039 | 6042 | saveSettingsDebounced(); |
| 6040 | 6043 | }); |
| 6041 | 6044 | |
| @@ -6046,6 +6049,7 @@ export function initOpenAI() { | ||
| 6046 | 6049 | |
| 6047 | 6050 | $('#openai_video_inlining').on('input', function () { |
| 6048 | 6051 | oai_settings.video_inlining = !!$(this).prop('checked'); |
| 6052 | + updateFeatureSupportFlags(); | |
| 6049 | 6053 | saveSettingsDebounced(); |
| 6050 | 6054 | }); |
| 6051 | 6055 | |
| @@ -6056,6 +6060,7 @@ export function initOpenAI() { | ||
| 6056 | 6060 | |
| 6057 | 6061 | $('#openai_function_calling').on('input', function () { |
| 6058 | 6062 | oai_settings.function_calling = !!$(this).prop('checked'); |
| 6063 | + updateFeatureSupportFlags(); | |
| 6059 | 6064 | saveSettingsDebounced(); |
| 6060 | 6065 | }); |
| 6061 | 6066 | |
| @@ -612,6 +612,20 @@ export class ToolManager { | ||
| 612 | 612 | } |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | + if (oai_settings.chat_completion_source === chat_completion_sources.OPENROUTER && Array.isArray(model_list)) { | |
| 616 | + const currentModel = model_list.find(model => model.id === oai_settings.openrouter_model); | |
| 617 | + if (Array.isArray(currentModel?.supported_parameters)) { | |
| 618 | + return currentModel.supported_parameters.includes('tools'); | |
| 619 | + } | |
| 620 | + } | |
| 621 | + | |
| 622 | + if (oai_settings.chat_completion_source === chat_completion_sources.MISTRALAI && Array.isArray(model_list)) { | |
| 623 | + const currentModel = model_list.find(model => model.id === oai_settings.mistralai_model); | |
| 624 | + if (currentModel && currentModel.capabilities) { | |
| 625 | + return currentModel.capabilities.function_calling; | |
| 626 | + } | |
| 627 | + } | |
| 628 | + | |
| 615 | 629 | const supportedSources = [ |
| 616 | 630 | chat_completion_sources.OPENAI, |
| 617 | 631 | chat_completion_sources.CUSTOM, |