Merge pull request #3537 from Kas1o/staging Updated Groq model options to sync with official playground

1a1afd00a1f2b2ad1795397d1c779eec63fa3932

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

Signed
3 files changed, +61 -37Showing whitespace changes
public/index.html+22 -10
@@ -3186,21 +3186,33 @@
31863186 </div>
31873187 <h4 data-i18n="Groq Model">Groq Model</h4>
31883188 <select id="model_groq_select">
31893189 <optgroup label="ProductionAlibaba ModelsCloud">
31903190 <option value="gemma2qwen-9b2.5-it32b">gemma2qwen-9b2.5-it32b</option>
31913191 <option value="llamaqwen-32.35-70bcoder-versatile32b">llamaqwen-32.35-70bcoder-versatile32b</option>
3192- <option value="llama-3.1-8b-instant">llama-3.1-8b-instant</option>
3192+ </optgroup>
3193- <option value="llama3-70b-8192">llama3-70b-8192</option>
3193+ <optgroup label="DeepSeek / Alibaba Cloud">
31943194 <option value="llama3deepseek-8br1-8192distill-qwen-32b">llama3deepseek-8br1-8192distill-qwen-32b</option>
3195- <option value="mixtral-8x7b-32768">mixtral-8x7b-32768</option>
31963195 </optgroup>
31973196 <optgroup label="PreviewDeepSeek Models/ Meta">
31983197 <option value="deepseek-r1-distill-llama-70b">deepseek-r1-distill-llama-70b</option>
3199- <option value="llama-3.3-70b-specdec">llama-3.3-70b-specdec</option>
3198+ </optgroup>
3199+ <optgroup label="Google">
3200+ <option value="gemma2-9b-it">gemma2-9b-it</option>
3201+ </optgroup>
3202+ <optgroup label="Meta">
3203+ <option value="llama-3.1-8b-instant">llama-3.1-8b-instant </option>
3204+ <option value="llama-3.2-11b-vision-preview">llama-3.2-11b-vision-preview </option>
32003205 <option value="llama-3.2-1b-preview">llama-3.2-1b-preview </option>
32013206 <option value="llama-3.2-3b-preview">llama-3.2-3b-preview </option>
3202- <option value="llama-3.2-11b-vision-preview">llama-3.2-11b-vision-preview</option>
32033207 <option value="llama-3.2-90b-vision-preview">llama-3.2-90b-vision-preview </option>
3208+ <option value="llama-3.3-70b-specdec">llama-3.3-70b-specdec </option>
3209+ <option value="llama-3.3-70b-versatile">llama-3.3-70b-versatile </option>
3210+ <option value="llama-guard-3-8b">llama-guard-3-8b </option>
3211+ <option value="llama3-70b-8192">llama3-70b-8192 </option>
3212+ <option value="llama3-8b-8192">llama3-8b-8192 </option>
3213+ </optgroup>
3214+ <optgroup label="Mistral AI">
3215+ <option value="mixtral-8x7b-32768">mixtral-8x7b-32768</option>
32043216 </optgroup>
32053217 </select>
32063218 </div>
public/scripts/openai.js+36 -27
@@ -4115,6 +4115,40 @@ 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+ 'llama-guard-3-8b': max_8k,
4136+ 'mixtral-8x7b-32768': max_32k,
4137+ 'deepseek-r1-distill-llama-70b': max_128k,
4138+ 'llama-3.3-70b-specdec': max_8k,
4139+ 'llama-3.2-1b-preview': max_128k,
4140+ 'llama-3.2-3b-preview': max_128k,
4141+ 'llama-3.2-11b-vision-preview': max_128k,
4142+ 'llama-3.2-90b-vision-preview': max_128k,
4143+ 'qwen-2.5-32b': max_128k,
4144+ 'deepseek-r1-distill-qwen-32b': max_128k,
4145+ 'deepseek-r1-distill-llama-70b-specdec': max_128k,
4146+ };
4147+
4148+ // Return context size if model found, otherwise default to 128k
4149+ return Object.entries(contextMap).find(([key]) => model.includes(key))?.[1] || max_128k;
4150+}
4151+
41184152async function onModelChange() {
41194153 biasCache = undefined;
41204154 let value = String($(this).val() || '');
@@ -4416,33 +4450,8 @@ async function onModelChange() {
44164450 }
44174451
44184452 if (oai_settings.chat_completion_source == chat_completion_sources.GROQ) {
4419- if (oai_settings.max_context_unlocked) {
4453+ const maxContext = getGroqMaxContext(oai_settings.groq_model, oai_settings.max_context_unlocked);
44204454 $('#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- }
44464455 oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
44474456 $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
44484457 oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai);
public/scripts/tokenizers.js+3 -0
@@ -694,6 +694,9 @@ export function getTokenizerModel() {
694694 }
695695
696696 if (oai_settings.chat_completion_source === chat_completion_sources.GROQ) {
697+ if (oai_settings.groq_model.includes('qwen')) {
698+ return qwen2Tokenizer;
699+ }
697700 if (oai_settings.groq_model.includes('llama-3') || oai_settings.groq_model.includes('llama3')) {
698701 return llama3Tokenizer;
699702 }