From 58519ae57474b9f275b6872851b11c1d711cc8e5 Mon Sep 17 00:00:00 2001 From: Zaki-1052 Date: Thu, 30 May 2024 17:20:36 -0700 Subject: [PATCH] models --- public/portal.html | 5 +++-- public/script.js | 4 ++++ server.js | 26 +++++++++++++------------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/public/portal.html b/public/portal.html index 04c0201..8ca19cc 100644 --- a/public/portal.html +++ b/public/portal.html @@ -23,8 +23,8 @@ - + @@ -33,12 +33,13 @@ - + + diff --git a/public/script.js b/public/script.js index 5037569..f0a7824 100644 --- a/public/script.js +++ b/public/script.js @@ -60,6 +60,7 @@ fetchConfig(); "Llama3-8b": "llama3-8b-8192", "Gemma-7b": "gemma-7b-it", "Codestral": "codestral-latest", + "Free Mixtral 8x7b": "mixtral-8x7b-32768", // Open Router Models "OpenRouter Auto": "openrouter/auto", "Nous: Capybara 7B (free)": "nousresearch/nous-capybara-7b:free", @@ -216,6 +217,7 @@ fetchConfig(); "llama3-8b-8192": "Llama3-8b", "gemma-7b-it": "Gemma-7b", "codestral-latest": "Codestral", + "mixtral-8x7b-32768": "Free Mixtral 8x7b", // Open Router Models "openrouter/auto": "OpenRouter Auto", "nousresearch/nous-capybara-7b:free": "Nous: Capybara 7B (free)", @@ -671,6 +673,8 @@ document.getElementById('model-gemma-it').addEventListener('click', () => select document.getElementById('model-gemma-it').addEventListener('mouseover', (event) => showCustomTooltip(modelDescriptions["gemma-7b-it"], event.currentTarget)); document.getElementById('model-codestral').addEventListener('click', () => selectModel('codestral-latest')); document.getElementById('model-codestral').addEventListener('mouseover', (event) => showCustomTooltip(modelDescriptions["codestral-latest"], event.currentTarget)); +document.getElementById('model-qroq-mistral-8x7b').addEventListener('click', () => selectModel('mixtral-8x7b-32768')); +document.getElementById('model-qroq-mistral-8x7b').addEventListener('mouseover', (event) => showCustomTooltip(modelDescriptions["mixtral-8x7b-32768"], event.currentTarget)); // select open router models lol diff --git a/server.js b/server.js index 2f2db86..ba10c94 100644 --- a/server.js +++ b/server.js @@ -1181,13 +1181,25 @@ if (modelID === 'gpt-4') { // Define the headers with the Authorization and, if needed, Organization // Determine the API to use based on modelID prefix - if (modelID.startsWith('gpt')) { + if (modelID.includes('/')) { + conversationHistory.push(user_input); + headers = { + 'Authorization': `Bearer ${process.env.OPENROUTER_API_KEY}`, + }; + apiUrl = 'https://openrouter.ai/api/v1/chat/completions'; + } else if (modelID.startsWith('gpt')) { conversationHistory.push(user_input); headers = { 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`, // 'OpenAI-Organization': 'process.env.ORGANIZATION' // Uncomment if using an organization ID }; apiUrl = 'https://api.openai.com/v1/chat/completions'; + } else if (modelID.startsWith('llama') || modelID.startsWith('gemma') || modelID === 'mixtral-8x7b-32768') { + conversationHistory.push(user_input); + headers = { + 'Authorization': `Bearer ${process.env.QROQ_API_KEY}`, + }; + apiUrl = 'https://api.groq.com/openai/v1/chat/completions'; } else if (modelID.includes('mistral') || modelID.includes('mixtral')) { conversationHistory.push(user_input); headers = { @@ -1219,18 +1231,6 @@ if (modelID === 'gpt-4') { // Add any Mistral-specific headers here if necessary }; apiUrl = 'https://api.anthropic.com/v1/messages'; - } else if (modelID.startsWith('llama') || modelID.startsWith('gemma')) { - conversationHistory.push(user_input); - headers = { - 'Authorization': `Bearer ${process.env.QROQ_API_KEY}`, - }; - apiUrl = 'https://api.groq.com/openai/v1/chat/completions'; - } else if (modelID.includes('/')) { - conversationHistory.push(user_input); - headers = { - 'Authorization': `Bearer ${process.env.OPENROUTER_API_KEY}`, - }; - apiUrl = 'https://openrouter.ai/api/v1/chat/completions'; } // Log the data payload just before sending it to the chosen API