Merge pull request #3836 from Erquint/staging Enable image inlining for visual models when connected to Mistral AI Le Platforme.
Signed| @@ -1975,7 +1975,7 @@ | |||
| 1975 | <span data-i18n="enable_functions_desc_3">Can be utilized by various extensions to provide additional functionality.</span> | 1975 | <span data-i18n="enable_functions_desc_3">Can be utilized by various extensions to provide additional functionality.</span> |
| 1976 | </div> | 1976 | </div> |
| 1977 | </div> | 1977 | </div> |
| 1978 | <div class="range-block" data-source="openai,openrouter,makersuite,claude,custom,01ai"> | 1978 | <div class="range-block" data-source="openai,openrouter,mistralai,makersuite,claude,custom,01ai"> |
| 1979 | <label for="openai_image_inlining" class="checkbox_label flexWrap widthFreeExpand"> | 1979 | <label for="openai_image_inlining" class="checkbox_label flexWrap widthFreeExpand"> |
| 1980 | <input id="openai_image_inlining" type="checkbox" /> | 1980 | <input id="openai_image_inlining" type="checkbox" /> |
| 1981 | <span data-i18n="Send inline images">Send inline images</span> | 1981 | <span data-i18n="Send inline images">Send inline images</span> |
| @@ -4166,6 +4166,80 @@ function getMaxContextWindowAI(value) { | |||
| 4166 | } | 4166 | } |
| 4167 | 4167 | ||
| 4168 | /** | 4168 | /** |
| 4169 | * Get the maximum context size for the Mistral model | ||
| 4170 | * @param {string} model Model identifier | ||
| 4171 | * @param {boolean} isUnlocked Whether context limits are unlocked | ||
| 4172 | * @returns {number} Maximum context size in tokens | ||
| 4173 | */ | ||
| 4174 | function getMistralMaxContext(model, isUnlocked) { | ||
| 4175 | if (isUnlocked) { | ||
| 4176 | return unlocked_max; | ||
| 4177 | } | ||
| 4178 | |||
| 4179 | if (Array.isArray(model_list) && model_list.length > 0) { | ||
| 4180 | const contextLength = model_list.find((record) => record.id === model)?.max_context_length; | ||
| 4181 | if (contextLength) { | ||
| 4182 | return contextLength; | ||
| 4183 | } | ||
| 4184 | } | ||
| 4185 | |||
| 4186 | const contextMap = { | ||
| 4187 | 'codestral-2411-rc5': 262144, | ||
| 4188 | 'codestral-2412': 262144, | ||
| 4189 | 'codestral-2501': 262144, | ||
| 4190 | 'codestral-latest': 262144, | ||
| 4191 | 'codestral-mamba-2407': 262144, | ||
| 4192 | 'codestral-mamba-latest': 262144, | ||
| 4193 | 'open-codestral-mamba': 262144, | ||
| 4194 | 'ministral-3b-2410': 131072, | ||
| 4195 | 'ministral-3b-latest': 131072, | ||
| 4196 | 'ministral-8b-2410': 131072, | ||
| 4197 | 'ministral-8b-latest': 131072, | ||
| 4198 | 'mistral-large-2407': 131072, | ||
| 4199 | 'mistral-large-2411': 131072, | ||
| 4200 | 'mistral-large-latest': 131072, | ||
| 4201 | 'mistral-large-pixtral-2411': 131072, | ||
| 4202 | 'mistral-tiny-2407': 131072, | ||
| 4203 | 'mistral-tiny-latest': 131072, | ||
| 4204 | 'open-mistral-nemo': 131072, | ||
| 4205 | 'open-mistral-nemo-2407': 131072, | ||
| 4206 | 'pixtral-12b': 131072, | ||
| 4207 | 'pixtral-12b-2409': 131072, | ||
| 4208 | 'pixtral-12b-latest': 131072, | ||
| 4209 | 'pixtral-large-2411': 131072, | ||
| 4210 | 'pixtral-large-latest': 131072, | ||
| 4211 | 'open-mixtral-8x22b': 65536, | ||
| 4212 | 'open-mixtral-8x22b-2404': 65536, | ||
| 4213 | 'codestral-2405': 32768, | ||
| 4214 | 'mistral-embed': 32768, | ||
| 4215 | 'mistral-large-2402': 32768, | ||
| 4216 | 'mistral-medium': 32768, | ||
| 4217 | 'mistral-medium-2312': 32768, | ||
| 4218 | 'mistral-medium-latest': 32768, | ||
| 4219 | 'mistral-moderation-2411': 32768, | ||
| 4220 | 'mistral-moderation-latest': 32768, | ||
| 4221 | 'mistral-ocr-2503': 32768, | ||
| 4222 | 'mistral-ocr-latest': 32768, | ||
| 4223 | 'mistral-saba-2502': 32768, | ||
| 4224 | 'mistral-saba-latest': 32768, | ||
| 4225 | 'mistral-small': 32768, | ||
| 4226 | 'mistral-small-2312': 32768, | ||
| 4227 | 'mistral-small-2402': 32768, | ||
| 4228 | 'mistral-small-2409': 32768, | ||
| 4229 | 'mistral-small-2501': 32768, | ||
| 4230 | 'mistral-small-2503': 32768, | ||
| 4231 | 'mistral-small-latest': 32768, | ||
| 4232 | 'mistral-tiny': 32768, | ||
| 4233 | 'mistral-tiny-2312': 32768, | ||
| 4234 | 'open-mistral-7b': 32768, | ||
| 4235 | 'open-mixtral-8x7b': 32768, | ||
| 4236 | }; | ||
| 4237 | |||
| 4238 | // Return context size if model found, otherwise default to 32k | ||
| 4239 | return Object.entries(contextMap).find(([key]) => model.includes(key))?.[1] || 32768; | ||
| 4240 | } | ||
| 4241 | |||
| 4242 | /** | ||
| 4169 | * Get the maximum context size for the Groq model | 4243 | * Get the maximum context size for the Groq model |
| 4170 | * @param {string} model Model identifier | 4244 | * @param {string} model Model identifier |
| 4171 | * @param {boolean} isUnlocked Whether context limits are unlocked | 4245 | * @param {boolean} isUnlocked Whether context limits are unlocked |
| @@ -4428,27 +4502,10 @@ async function onModelChange() { | |||
| 4428 | } | 4502 | } |
| 4429 | 4503 | ||
| 4430 | if (oai_settings.chat_completion_source === chat_completion_sources.MISTRALAI) { | 4504 | if (oai_settings.chat_completion_source === chat_completion_sources.MISTRALAI) { |
| 4431 | if (oai_settings.max_context_unlocked) { | 4505 | const maxContext = getMistralMaxContext(oai_settings.mistralai_model, oai_settings.max_context_unlocked); |
| 4432 | $('#openai_max_context').attr('max', unlocked_max); | 4506 | $('#openai_max_context').attr('max', maxContext); |
| 4433 | } else if (['codestral-latest', 'codestral-mamba-2407', 'codestral-2411-rc5', 'codestral-2412', 'codestral-2501'].includes(oai_settings.mistralai_model)) { | ||
| 4434 | $('#openai_max_context').attr('max', max_256k); | ||
| 4435 | } else if (['mistral-large-2407', 'mistral-large-2411', 'mistral-large-pixtral-2411', 'mistral-large-latest'].includes(oai_settings.mistralai_model)) { | ||
| 4436 | $('#openai_max_context').attr('max', max_128k); | ||
| 4437 | } else if (oai_settings.mistralai_model.includes('mistral-nemo')) { | ||
| 4438 | $('#openai_max_context').attr('max', max_128k); | ||
| 4439 | } else if (oai_settings.mistralai_model.includes('mixtral-8x22b')) { | ||
| 4440 | $('#openai_max_context').attr('max', max_64k); | ||
| 4441 | } else if (oai_settings.mistralai_model.includes('pixtral')) { | ||
| 4442 | $('#openai_max_context').attr('max', max_128k); | ||
| 4443 | } else if (oai_settings.mistralai_model.includes('ministral')) { | ||
| 4444 | $('#openai_max_context').attr('max', max_32k); | ||
| 4445 | } else { | ||
| 4446 | $('#openai_max_context').attr('max', max_32k); | ||
| 4447 | } | ||
| 4448 | oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max'))); | 4507 | oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max'))); |
| 4449 | $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input'); | 4508 | $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input'); |
| 4450 | |||
| 4451 | //mistral also caps temp at 1.0 | ||
| 4452 | oai_settings.temp_openai = Math.min(claude_max_temp, oai_settings.temp_openai); | 4509 | oai_settings.temp_openai = Math.min(claude_max_temp, oai_settings.temp_openai); |
| 4453 | $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input'); | 4510 | $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input'); |
| 4454 | } | 4511 | } |
| @@ -5006,7 +5063,9 @@ export function isImageInliningSupported() { | |||
| 5006 | 'o1-2024-12-17', | 5063 | 'o1-2024-12-17', |
| 5007 | 'chatgpt-4o-latest', | 5064 | 'chatgpt-4o-latest', |
| 5008 | 'yi-vision', | 5065 | 'yi-vision', |
| 5009 | 'pixtral-latest', | 5066 | 'mistral-large-pixtral-2411', |
| 5067 | 'mistral-small-2503', | ||
| 5068 | 'mistral-small-latest', | ||
| 5010 | 'pixtral-12b-latest', | 5069 | 'pixtral-12b-latest', |
| 5011 | 'pixtral-12b', | 5070 | 'pixtral-12b', |
| 5012 | 'pixtral-12b-2409', | 5071 | 'pixtral-12b-2409', |