Groq: Add new models and multimodal captions
| @@ -2954,16 +2954,31 @@ | ||
| 2954 | 2954 | </div> |
| 2955 | 2955 | <h4 data-i18n="Groq Model">Groq Model</h4> |
| 2956 | 2956 | <select id="model_groq_select"> |
| 2957 | - <option value="llama-3.1-405b-reasoning">llama-3.1-405b-reasoning</option> | |
| 2957 | + <optgroup label="Llama 3.2"> | |
| 2958 | 2958 | <option value="llama-3.12-70b1b-versatilepreview">llama-3.12-70b1b-versatilepreview</option> |
| 2959 | 2959 | <option value="llama-3.12-8b3b-instantpreview">llama-3.12-8b3b-instantpreview</option> |
| 2960 | 2960 | <option value="llama3-groq-70bllama-81923.2-tool11b-usevision-preview">llama3-groq-70bllama-81923.2-tool11b-usevision-preview</option> |
| 2961 | 2961 | <option value="llama3-groq-8bllama-81923.2-tool90b-usevision-preview">llama3-groq-8bllama-81923.2-tool90b-usevision-preview</option> |
| 2962 | - <option value="llama3-8b-8192">llama3-8b-8192</option> | |
| 2962 | + </optgroup> | |
| 2963 | - <option value="llama3-70b-8192">llama3-70b-8192</option> | |
| 2963 | + <optgroup label="Llama 3.1"> | |
| 2964 | 2964 | <option value="mixtralllama-8x7b3.1-327688b-instant">mixtralllama-8x7b3.1-327688b-instant</option> |
| 2965 | 2965 | <option value="gemmallama-7b3.1-it70b-versatile">gemmallama-7b3.1-it70b-versatile</option> |
| 2966 | 2966 | <option value="gemma2llama-9b3.1-it405b-reasoning">gemma2llama-9b3.1-it405b-reasoning</option> |
| 2967 | + </optgroup> | |
| 2968 | + <optgroup label="Llama 3"> | |
| 2969 | + <option value="llama3-groq-8b-8192-tool-use-preview">llama3-groq-8b-8192-tool-use-preview</option> | |
| 2970 | + <option value="llama3-groq-70b-8192-tool-use-preview">llama3-groq-70b-8192-tool-use-preview</option> | |
| 2971 | + <option value="llama3-8b-8192">llama3-8b-8192</option> | |
| 2972 | + <option value="llama3-70b-8192">llama3-70b-8192</option> | |
| 2973 | + </optgroup> | |
| 2974 | + <optgroup label="Gemma"> | |
| 2975 | + <option value="gemma-7b-it">gemma-7b-it</option> | |
| 2976 | + <option value="gemma2-9b-it">gemma2-9b-it</option> | |
| 2977 | + </optgroup> | |
| 2978 | + <optgroup label="Other"> | |
| 2979 | + <option value="mixtral-8x7b-32768">mixtral-8x7b-32768</option> | |
| 2980 | + <option value="llava-v1.5-7b-4096-preview">llava-v1.5-7b-4096-preview</option> | |
| 2981 | + </optgroup> | |
| 2967 | 2982 | </select> |
| 2968 | 2983 | </div> |
| 2969 | 2984 | <div id="perplexity_form" data-source="perplexity"> |
| @@ -403,6 +403,7 @@ jQuery(async function () { | ||
| 403 | 403 | (extension_settings.caption.source === 'multimodal' && extension_settings.caption.multimodal_api === 'openai' && (secret_state[SECRET_KEYS.OPENAI] || extension_settings.caption.allow_reverse_proxy)) || |
| 404 | 404 | (extension_settings.caption.source === 'multimodal' && extension_settings.caption.multimodal_api === 'openrouter' && secret_state[SECRET_KEYS.OPENROUTER]) || |
| 405 | 405 | (extension_settings.caption.source === 'multimodal' && extension_settings.caption.multimodal_api === 'zerooneai' && secret_state[SECRET_KEYS.ZEROONEAI]) || |
| 406 | + (extension_settings.caption.source === 'multimodal' && extension_settings.caption.multimodal_api === 'groq' && secret_state[SECRET_KEYS.GROQ]) || | |
| 406 | 407 | (extension_settings.caption.source === 'multimodal' && extension_settings.caption.multimodal_api === 'mistral' && (secret_state[SECRET_KEYS.MISTRALAI] || extension_settings.caption.allow_reverse_proxy)) || |
| 407 | 408 | (extension_settings.caption.source === 'multimodal' && extension_settings.caption.multimodal_api === 'google' && (secret_state[SECRET_KEYS.MAKERSUITE] || extension_settings.caption.allow_reverse_proxy)) || |
| 408 | 409 | (extension_settings.caption.source === 'multimodal' && extension_settings.caption.multimodal_api === 'anthropic' && (secret_state[SECRET_KEYS.CLAUDE] || extension_settings.caption.allow_reverse_proxy)) || |
| @@ -21,6 +21,7 @@ | ||
| 21 | 21 | <option value="anthropic">Anthropic</option> |
| 22 | 22 | <option value="custom" data-i18n="Custom (OpenAI-compatible)">Custom (OpenAI-compatible)</option> |
| 23 | 23 | <option value="google">Google AI Studio</option> |
| 24 | + <option value="groq">Groq</option> | |
| 24 | 25 | <option value="koboldcpp">KoboldCpp</option> |
| 25 | 26 | <option value="llamacpp">llama.cpp</option> |
| 26 | 27 | <option value="mistral">MistralAI</option> |
| @@ -60,6 +61,9 @@ | ||
| 60 | 61 | <option data-type="google" value="gemini-1.5-pro-exp-0801">gemini-1.5-pro-exp-0801</option> |
| 61 | 62 | <option data-type="google" value="gemini-1.5-pro-exp-0827">gemini-1.5-pro-exp-0827</option> |
| 62 | 63 | <option data-type="google" value="gemini-pro-vision">gemini-pro-vision</option> |
| 64 | + <option data-type="groq" value="llama-3.2-11b-vision-preview">llama-3.2-11b-vision-preview</option> | |
| 65 | + <option data-type="groq" value="llama-3.2-90b-vision-preview">llama-3.2-90b-vision-preview</option> | |
| 66 | + <option data-type="groq" value="llava-v1.5-7b-4096-preview">llava-v1.5-7b-4096-preview</option> | |
| 63 | 67 | <option data-type="openrouter" value="openai/gpt-4-vision-preview">openai/gpt-4-vision-preview</option> |
| 64 | 68 | <option data-type="openrouter" value="openai/gpt-4o">openai/gpt-4o</option> |
| 65 | 69 | <option data-type="openrouter" value="openai/gpt-4o-2024-05-13">openai/gpt-4o-2024-05-13</option> |
| @@ -36,7 +36,7 @@ export async function getMultimodalCaption(base64Img, prompt) { | ||
| 36 | 36 | const isVllm = extension_settings.caption.multimodal_api === 'vllm'; |
| 37 | 37 | const base64Bytes = base64Img.length * 0.75; |
| 38 | 38 | const compressionLimit = 2 * 1024 * 1024; |
| 39 | 39 | if ((['google', 'openrouter', 'mistral', 'groq'].includes(extension_settings.caption.multimodal_api) && base64Bytes > compressionLimit) || isOoba || isKoboldCpp) { |
| 40 | 40 | const maxSide = 1024; |
| 41 | 41 | base64Img = await createThumbnail(base64Img, maxSide, maxSide, 'image/jpeg'); |
| 42 | 42 | } |
| @@ -135,6 +135,10 @@ function throwIfInvalidModel(useReverseProxy) { | ||
| 135 | 135 | throw new Error('01.AI API key is not set.'); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | + if (extension_settings.caption.multimodal_api === 'groq' && !secret_state[SECRET_KEYS.GROQ]) { | |
| 139 | + throw new Error('Groq API key is not set.'); | |
| 140 | + } | |
| 141 | + | |
| 138 | 142 | if (extension_settings.caption.multimodal_api === 'google' && !secret_state[SECRET_KEYS.MAKERSUITE] && !useReverseProxy) { |
| 139 | 143 | throw new Error('Google AI Studio API key is not set.'); |
| 140 | 144 | } |
| @@ -4196,7 +4196,10 @@ async function onModelChange() { | ||
| 4196 | 4196 | if (oai_settings.max_context_unlocked) { |
| 4197 | 4197 | $('#openai_max_context').attr('max', unlocked_max); |
| 4198 | 4198 | } |
| 4199 | 4199 | else if (oai_settings.groq_model.includes('llama-3.12') && oai_settings.groq_model.includes('-preview')) { |
| 4200 | + $('#openai_max_context').attr('max', max_8k); | |
| 4201 | + } | |
| 4202 | + else if (oai_settings.groq_model.includes('llama-3.2') || oai_settings.groq_model.includes('llama-3.1')) { | |
| 4200 | 4203 | $('#openai_max_context').attr('max', max_128k); |
| 4201 | 4204 | } |
| 4202 | 4205 | else if (oai_settings.groq_model.includes('llama3-groq')) { |
| @@ -55,6 +55,10 @@ router.post('/caption-image', jsonParser, async (request, response) => { | ||
| 55 | 55 | key = readSecret(request.user.directories, SECRET_KEYS.MISTRALAI); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | + if (request.body.api === 'groq') { | |
| 59 | + key = readSecret(request.user.directories, SECRET_KEYS.GROQ); | |
| 60 | + } | |
| 61 | + | |
| 58 | 62 | if (!key && !request.body.reverse_proxy && ['custom', 'ooba', 'koboldcpp', 'vllm'].includes(request.body.api) === false) { |
| 59 | 63 | console.log('No key found for API', request.body.api); |
| 60 | 64 | return response.sendStatus(400); |
| @@ -111,6 +115,10 @@ router.post('/caption-image', jsonParser, async (request, response) => { | ||
| 111 | 115 | apiUrl = 'https://api.01.ai/v1/chat/completions'; |
| 112 | 116 | } |
| 113 | 117 | |
| 118 | + if (request.body.api === 'groq') { | |
| 119 | + apiUrl = 'https://api.groq.com/openai/v1/chat/completions'; | |
| 120 | + } | |
| 121 | + | |
| 114 | 122 | if (request.body.api === 'mistral') { |
| 115 | 123 | apiUrl = 'https://api.mistral.ai/v1/chat/completions'; |
| 116 | 124 | } |