Add context sizes for new groq models

15769a7643d3c4e063d60749bd2654ba9dc6bbab

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +35 -27Showing whitespace changes
public/scripts/openai.js+35 -27
@@ -4115,6 +4115,39 @@ function getMaxContextWindowAI(value) {
41154115 }
41164116}
41174117
4118+/**
4119+ * Get the maximum context size for the Groq model
4120+ * @param {string} model Model identifier
4121+ * @param {boolean} isUnlocked Whether context limits are unlocked
4122+ * @returns {number} Maximum context size in tokens
4123+ */
4124+function getGroqMaxContext(model, isUnlocked) {
4125+ if (isUnlocked) {
4126+ return unlocked_max;
4127+ }
4128+
4129+ const contextMap = {
4130+ 'gemma2-9b-it': max_8k,
4131+ 'llama-3.3-70b-versatile': max_128k,
4132+ 'llama-3.1-8b-instant': max_128k,
4133+ 'llama3-70b-8192': max_8k,
4134+ 'llama3-8b-8192': max_8k,
4135+ 'mixtral-8x7b-32768': max_32k,
4136+ 'deepseek-r1-distill-llama-70b': max_128k,
4137+ 'llama-3.3-70b-specdec': max_8k,
4138+ 'llama-3.2-1b-preview': max_128k,
4139+ 'llama-3.2-3b-preview': max_128k,
4140+ 'llama-3.2-11b-vision-preview': max_128k,
4141+ 'llama-3.2-90b-vision-preview': max_128k,
4142+ 'qwen-2.5-32b': max_128k,
4143+ 'deepseek-r1-distill-qwen-32b': max_128k,
4144+ 'deepseek-r1-distill-llama-70b-specdec': max_128k,
4145+ };
4146+
4147+ // Return context size if model found, otherwise default to 128k
4148+ return Object.entries(contextMap).find(([key]) => model.includes(key))?.[1] || max_128k;
4149+}
4150+
41184151async function onModelChange() {
41194152 biasCache = undefined;
41204153 let value = String($(this).val() || '');
@@ -4416,33 +4449,8 @@ async function onModelChange() {
44164449 }
44174450
44184451 if (oai_settings.chat_completion_source == chat_completion_sources.GROQ) {
4419- if (oai_settings.max_context_unlocked) {
4452+ const maxContext = getGroqMaxContext(oai_settings.groq_model, oai_settings.max_context_unlocked);
44204453 $('#openai_max_context').attr('max', unlocked_maxmaxContext);
4421- } else if (oai_settings.groq_model.includes('gemma2-9b-it')) {
4422- $('#openai_max_context').attr('max', max_8k);
4423- } else if (oai_settings.groq_model.includes('llama-3.3-70b-versatile')) {
4424- $('#openai_max_context').attr('max', max_128k);
4425- } else if (oai_settings.groq_model.includes('llama-3.1-8b-instant')) {
4426- $('#openai_max_context').attr('max', max_128k);
4427- } else if (oai_settings.groq_model.includes('llama3-70b-8192')) {
4428- $('#openai_max_context').attr('max', max_8k);
4429- } else if (oai_settings.groq_model.includes('llama3-8b-8192')) {
4430- $('#openai_max_context').attr('max', max_8k);
4431- } else if (oai_settings.groq_model.includes('mixtral-8x7b-32768')) {
4432- $('#openai_max_context').attr('max', max_32k);
4433- } else if (oai_settings.groq_model.includes('deepseek-r1-distill-llama-70b')) {
4434- $('#openai_max_context').attr('max', max_128k);
4435- } else if (oai_settings.groq_model.includes('llama-3.3-70b-specdec')) {
4436- $('#openai_max_context').attr('max', max_8k);
4437- } else if (oai_settings.groq_model.includes('llama-3.2-1b-preview')) {
4438- $('#openai_max_context').attr('max', max_128k);
4439- } else if (oai_settings.groq_model.includes('llama-3.2-3b-preview')) {
4440- $('#openai_max_context').attr('max', max_128k);
4441- } else if (oai_settings.groq_model.includes('llama-3.2-11b-vision-preview')) {
4442- $('#openai_max_context').attr('max', max_128k);
4443- } else if (oai_settings.groq_model.includes('llama-3.2-90b-vision-preview')) {
4444- $('#openai_max_context').attr('max', max_128k);
4445- }
44464454 oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
44474455 $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
44484456 oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai);