Add Jamba 1.6 models Closes #3633

ff5835278b6c0d7539228130d9a9e0c6883d1cb6

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

3 files changed, +21 -7Showing whitespace changes
public/index.html+9 -1
@@ -3078,7 +3078,15 @@
3078 <div>3078 <div>
3079 <h4 data-i18n="AI21 Model">AI21 Model</h4>3079 <h4 data-i18n="AI21 Model">AI21 Model</h4>
3080 <select id="model_ai21_select">3080 <select id="model_ai21_select">
3081 <optgroup label="Jamba 1.5">3081 <optgroup label="Jamba (Latest)">
3082 <option value="jamba-mini">jamba-mini</option>
3083 <option value="jamba-large">jamba-large</option>
3084 </optgroup>
3085 <optgroup label="Jamba 1.6">
3086 <option value="jamba-1.6-mini">jamba-1.6-mini</option>
3087 <option value="jamba-1.6-large">jamba-1.6-large</option>
3088 </optgroup>
3089 <optgroup label="Jamba 1.5 (Deprecated)">
3082 <option value="jamba-1.5-mini">jamba-1.5-mini</option>3090 <option value="jamba-1.5-mini">jamba-1.5-mini</option>
3083 <option value="jamba-1.5-large">jamba-1.5-large</option>3091 <option value="jamba-1.5-large">jamba-1.5-large</option>
3084 </optgroup>3092 </optgroup>
public/scripts/openai.js+5 -5
@@ -337,7 +337,7 @@ const default_settings = {
337 openai_model: 'gpt-4-turbo',337 openai_model: 'gpt-4-turbo',
338 claude_model: 'claude-3-5-sonnet-20240620',338 claude_model: 'claude-3-5-sonnet-20240620',
339 google_model: 'gemini-1.5-pro',339 google_model: 'gemini-1.5-pro',
340 ai21_model: 'jamba-1.5-large',340 ai21_model: 'jamba-1.6-large',
341 mistralai_model: 'mistral-large-latest',341 mistralai_model: 'mistral-large-latest',
342 cohere_model: 'command-r-plus',342 cohere_model: 'command-r-plus',
343 perplexity_model: 'sonar-pro',343 perplexity_model: 'sonar-pro',
@@ -417,7 +417,7 @@ const oai_settings = {
417 openai_model: 'gpt-4-turbo',417 openai_model: 'gpt-4-turbo',
418 claude_model: 'claude-3-5-sonnet-20240620',418 claude_model: 'claude-3-5-sonnet-20240620',
419 google_model: 'gemini-1.5-pro',419 google_model: 'gemini-1.5-pro',
420 ai21_model: 'jamba-1.5-large',420 ai21_model: 'jamba-1.6-large',
421 mistralai_model: 'mistral-large-latest',421 mistralai_model: 'mistral-large-latest',
422 cohere_model: 'command-r-plus',422 cohere_model: 'command-r-plus',
423 perplexity_model: 'sonar-pro',423 perplexity_model: 'sonar-pro',
@@ -3251,7 +3251,7 @@ function loadOpenAISettings(data, settings) {
3251 }3251 }
32523252
3253 if (oai_settings.ai21_model.startsWith('j2-')) {3253 if (oai_settings.ai21_model.startsWith('j2-')) {
3254 oai_settings.ai21_model = 'jamba-1.5-large';3254 oai_settings.ai21_model = 'jamba-1.6-large';
3255 }3255 }
32563256
3257 if (settings.wrap_in_quotes !== undefined) oai_settings.wrap_in_quotes = !!settings.wrap_in_quotes;3257 if (settings.wrap_in_quotes !== undefined) oai_settings.wrap_in_quotes = !!settings.wrap_in_quotes;
@@ -4208,7 +4208,7 @@ async function onModelChange() {
42084208
4209 if ($(this).is('#model_ai21_select')) {4209 if ($(this).is('#model_ai21_select')) {
4210 if (value === '' || value.startsWith('j2-')) {4210 if (value === '' || value.startsWith('j2-')) {
4211 value = 'jamba-1.5-large';4211 value = 'jamba-1.6-large';
4212 $('#model_ai21_select').val(value);4212 $('#model_ai21_select').val(value);
4213 }4213 }
42144214
@@ -4485,7 +4485,7 @@ async function onModelChange() {
4485 if (oai_settings.chat_completion_source == chat_completion_sources.AI21) {4485 if (oai_settings.chat_completion_source == chat_completion_sources.AI21) {
4486 if (oai_settings.max_context_unlocked) {4486 if (oai_settings.max_context_unlocked) {
4487 $('#openai_max_context').attr('max', unlocked_max);4487 $('#openai_max_context').attr('max', unlocked_max);
4488 } else if (oai_settings.ai21_model.includes('jamba-1.5') || oai_settings.ai21_model.includes('jamba-instruct')) {4488 } else if (oai_settings.ai21_model.startsWith('jamba-')) {
4489 $('#openai_max_context').attr('max', max_256k);4489 $('#openai_max_context').attr('max', max_256k);
4490 }4490 }
44914491
src/endpoints/backends/chat-completions.js+7 -1
@@ -499,6 +499,12 @@ async function sendMakerSuiteRequest(request, response) {
499async function sendAI21Request(request, response) {499async function sendAI21Request(request, response) {
500 if (!request.body) return response.sendStatus(400);500 if (!request.body) return response.sendStatus(400);
501501
502 const apiKey = readSecret(request.user.directories, SECRET_KEYS.AI21);
503 if (!apiKey) {
504 console.warn('AI21 API key is missing.');
505 return response.status(400).send({ error: true });
506 }
507
502 const controller = new AbortController();508 const controller = new AbortController();
503 console.debug(request.body.messages);509 console.debug(request.body.messages);
504 request.socket.removeAllListeners('close');510 request.socket.removeAllListeners('close');
@@ -520,7 +526,7 @@ async function sendAI21Request(request, response) {
520 headers: {526 headers: {
521 accept: 'application/json',527 accept: 'application/json',
522 'content-type': 'application/json',528 'content-type': 'application/json',
523 Authorization: `Bearer ${readSecret(request.user.directories, SECRET_KEYS.AI21)}`,529 Authorization: `Bearer ${apiKey}`,
524 },530 },
525 body: JSON.stringify(body),531 body: JSON.stringify(body),
526 signal: controller.signal,532 signal: controller.signal,