0fe0aa08 by Marwin Cañeta

Merge branch 'master' into 31531_apply_tokenization_on_other_llms

# Conflicts:
#	index.js
2 parents d150f036 7a230c24
...@@ -105,7 +105,7 @@ function App() { ...@@ -105,7 +105,7 @@ function App() {
105 } 105 }
106 106
107 if(currentModel === "openchat_3.5" || currentModel === "zephyr-7B-beta" 107 if(currentModel === "openchat_3.5" || currentModel === "zephyr-7B-beta"
108 || currentModel === "meta-llama/Llama-3-8b-chat-hf" || currentModel === "google/gemma-7b-it") { 108 || currentModel === "meta-llama/Llama-3-8b-chat-hf" || currentModel === "google/gemma-2-9b-it") {
109 // "gpt-3.5-turbo" 109 // "gpt-3.5-turbo"
110 let chatLogOpenSourceNew = [...chatLogOpenSource, { role: "user", content: chatInput }]; 110 let chatLogOpenSourceNew = [...chatLogOpenSource, { role: "user", content: chatInput }];
111 setChatLogOpenSource(chatLogOpenSourceNew); 111 setChatLogOpenSource(chatLogOpenSourceNew);
......
...@@ -93,7 +93,7 @@ app.post('/api', async (req, res) => { ...@@ -93,7 +93,7 @@ app.post('/api', async (req, res) => {
93 } 93 }
94 94
95 if (currentModel == "openchat_3.5" || currentModel == "zephyr-7B-beta" 95 if (currentModel == "openchat_3.5" || currentModel == "zephyr-7B-beta"
96 || currentModel == "google/gemma-7b-it" || currentModel == "meta-llama/Llama-3-8b-chat-hf" 96 || currentModel == "google/gemma-2-9b-it" || currentModel == "meta-llama/Llama-3-8b-chat-hf"
97 ) { 97 ) {
98 runOpensource(req, res); 98 runOpensource(req, res);
99 99
...@@ -289,14 +289,23 @@ async function runOpensource(req, res) { ...@@ -289,14 +289,23 @@ async function runOpensource(req, res) {
289 const response = await axios.post(endpoint_api_url + '/chat/completions', { 289 const response = await axios.post(endpoint_api_url + '/chat/completions', {
290 model: currentModel, 290 model: currentModel,
291 messages: JSON.parse(message), 291 messages: JSON.parse(message),
292 temperature 292 max_tokens: 2048,
293 temperature,
294 top_p: 0.7,
295 top_k: 50,
296 repetition_penalty: 1
293 }, { 297 }, {
294 headers: { 298 headers: {
295 'Content-Type': 'application/json', 299 'Content-Type': 'application/json',
296 'Authorization': 'Bearer ' + api_key 300 'Authorization': 'Bearer ' + api_key
297 }, 301 },
298 }).catch(error => { 302 }).catch(error => {
303 if(error.response?.data?.error?.param === 'max_tokens') {
304 input = "The output for your prompt is too long for us to process. Please reduce your prompt and try again.";
305 } else {
299 error_msg = error.response.statusText ? error.response.statusText : ''; 306 error_msg = error.response.statusText ? error.response.statusText : '';
307 }
308 console.log("err",error.response.data.error);
300 }); 309 });
301 310
302 if (error_msg !== '') { 311 if (error_msg !== '') {
...@@ -405,7 +414,7 @@ async function setChatUsage(params) { ...@@ -405,7 +414,7 @@ async function setChatUsage(params) {
405 414
406 async function validation (aiwp_app_id, req, res) { 415 async function validation (aiwp_app_id, req, res) {
407 const aiwp_logged_in = req.cookies[user_secret_id] ? decodeURIComponent(req.cookies[user_secret_id]) : ""; 416 const aiwp_logged_in = req.cookies[user_secret_id] ? decodeURIComponent(req.cookies[user_secret_id]) : "";
408 const limit = req.cookies["WcvYPABR"] ? parseInt(req.cookies["WcvYPABR"].replace(/\D/g, '')) : -1; 417 const limit = req.cookies["WcvYPABR"] ? parseInt(req.cookies["WcvYPABR"].replace(/\D/g, '')) : 3;
409 let IS_FREE_USER = false; 418 let IS_FREE_USER = false;
410 let TRIED_USAGE = 0; 419 let TRIED_USAGE = 0;
411 420
...@@ -458,39 +467,31 @@ async function validation (aiwp_app_id, req, res) { ...@@ -458,39 +467,31 @@ async function validation (aiwp_app_id, req, res) {
458 467
459 // Get Models Route 468 // Get Models Route
460 app.get('/models', async (req, res) => { 469 app.get('/models', async (req, res) => {
461 const response = await openai.listModels(); 470 const openai_models = process.env.OPENAI_MODELS ? JSON.parse(process.env.OPENAI_MODELS) : [{"value": "gpt-3.5-turbo", "label": "GPT-3.5"}];
462 const models = response.data;
463 const opensource_models = process.env.OPENSOURCE_MODELS ? JSON.parse(process.env.OPENSOURCE_MODELS) : []; 471 const opensource_models = process.env.OPENSOURCE_MODELS ? JSON.parse(process.env.OPENSOURCE_MODELS) : [];
464 472
465 models.data = models.data.filter((model) => { 473 const models = {
466 return model.id.indexOf('gpt-3') === 0 474 data: []
475 };
476
477 openai_models.forEach((model) => {
478 models.data.push({
479 id: model.value,
480 label: model.label,
481 name: model.label,
482 beta: false,
483 });
467 }) 484 })
468 485
469 opensource_models.forEach((model) => { 486 opensource_models.forEach((model) => {
470 models.data.push({ 487 models.data.push({
471 id: model.value, 488 id: model.value,
472 label: model.label, 489 label: model.label,
490 name: model.label,
473 beta: true, 491 beta: true,
474 }); 492 });
475 }) 493 })
476 494
477
478 const months = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
479 // add name
480 models.data.forEach((model) => {
481 if (model.id.includes('gpt-3')) {
482 const d = new Date(model.created * 1000);
483 let month = months[d.getMonth()];
484 model.name = 'GPT-3.5 ' + month + ' ' + d.getDate();
485 } else if (model.id == 'dall-e-2') {
486 model.name = 'DALL-E 2';
487 } else if (model.id == 'dall-e-3') {
488 model.name = 'DALL-E 3';
489 } else {
490 model.name = model.label ? model.label: model.id;
491 }
492 })
493
494 res.json({ 495 res.json({
495 models 496 models
496 }) 497 })
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!