e45cfbc0 by Jonille Arreglo

31675_chatbotplus_llm

1 parent 4fa0b1d3
...@@ -48,14 +48,14 @@ function App() { ...@@ -48,14 +48,14 @@ function App() {
48 return 0; 48 return 0;
49 }); 49 });
50 let model_list = []; 50 let model_list = [];
51 for( var i = 1; i < data.models.data.length; i++ ) { 51 for( var i = 0; i < data.models.data.length; i++ ) {
52 let model = data.models.data[i]; 52 let model = data.models.data[i];
53 if( !(model.id === "whisper-1" 53 if( !(model.id === "whisper-1"
54 || model.id === "gpt-4" 54 || model.id === "gpt-4"
55 || model.id === "gpt-4-0314" 55 || model.id === "gpt-4-0314"
56 || model.id === "gpt-4-0613") ) model_list.push(model); 56 || model.id === "gpt-4-0613") ) model_list.push(model);
57 } 57 }
58 setModels(model_list) 58 setModels(model_list);
59 }) 59 })
60 } 60 }
61 61
...@@ -104,7 +104,8 @@ function App() { ...@@ -104,7 +104,8 @@ function App() {
104 messages = JSON.stringify(chatLogTurboNew); 104 messages = JSON.stringify(chatLogTurboNew);
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 // "gpt-3.5-turbo" 109 // "gpt-3.5-turbo"
109 let chatLogOpenSourceNew = [...chatLogOpenSource, { role: "user", content: chatInput }]; 110 let chatLogOpenSourceNew = [...chatLogOpenSource, { role: "user", content: chatInput }];
110 setChatLogOpenSource(chatLogOpenSourceNew); 111 setChatLogOpenSource(chatLogOpenSourceNew);
...@@ -150,7 +151,7 @@ function App() { ...@@ -150,7 +151,7 @@ function App() {
150 }); 151 });
151 userModifiedInput = ""; 152 userModifiedInput = "";
152 } 153 }
153 154
154 chatLogTurboNew.push({ role: "user", content: userModifiedInput }); 155 chatLogTurboNew.push({ role: "user", content: userModifiedInput });
155 chatLogTurboNew.push({ role: "assistant", content: parsedData }); 156 chatLogTurboNew.push({ role: "assistant", content: parsedData });
156 157
......
...@@ -92,7 +92,9 @@ app.post('/api', async (req, res) => { ...@@ -92,7 +92,9 @@ app.post('/api', async (req, res) => {
92 return; 92 return;
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"
97 ) {
96 runOpensource(req, res); 98 runOpensource(req, res);
97 99
98 return; 100 return;
...@@ -284,6 +286,7 @@ async function runOpensource(req, res) { ...@@ -284,6 +286,7 @@ async function runOpensource(req, res) {
284 const endpoint_api_url = get_endpoint_api_url(currentModel); 286 const endpoint_api_url = get_endpoint_api_url(currentModel);
285 const api_key = get_endpoint_api_key(currentModel); 287 const api_key = get_endpoint_api_key(currentModel);
286 const response = await axios.post(endpoint_api_url + '/chat/completions', { 288 const response = await axios.post(endpoint_api_url + '/chat/completions', {
289 model: currentModel,
287 messages: JSON.parse(message), 290 messages: JSON.parse(message),
288 temperature 291 temperature
289 }, { 292 }, {
...@@ -465,7 +468,7 @@ async function validation (aiwp_app_id, req, res) { ...@@ -465,7 +468,7 @@ async function validation (aiwp_app_id, req, res) {
465 app.get('/models', async (req, res) => { 468 app.get('/models', async (req, res) => {
466 const response = await openai.listModels(); 469 const response = await openai.listModels();
467 const models = response.data; 470 const models = response.data;
468 const opensource_models = process.env.OPENSOURCE_MODELS ? process.env.OPENSOURCE_MODELS.split(',') : []; 471 const opensource_models = process.env.OPENSOURCE_MODELS ? JSON.parse(process.env.OPENSOURCE_MODELS) : [];
469 472
470 models.data = models.data.filter((model) => { 473 models.data = models.data.filter((model) => {
471 return model.id.indexOf('gpt-3') === 0 474 return model.id.indexOf('gpt-3') === 0
...@@ -473,7 +476,8 @@ app.get('/models', async (req, res) => { ...@@ -473,7 +476,8 @@ app.get('/models', async (req, res) => {
473 476
474 opensource_models.forEach((model) => { 477 opensource_models.forEach((model) => {
475 models.data.push({ 478 models.data.push({
476 id: model, 479 id: model.value,
480 label: model.label,
477 beta: true, 481 beta: true,
478 }); 482 });
479 }) 483 })
...@@ -491,7 +495,7 @@ app.get('/models', async (req, res) => { ...@@ -491,7 +495,7 @@ app.get('/models', async (req, res) => {
491 } else if (model.id == 'dall-e-3') { 495 } else if (model.id == 'dall-e-3') {
492 model.name = 'DALL-E 3'; 496 model.name = 'DALL-E 3';
493 } else { 497 } else {
494 model.name = model.id; 498 model.name = model.label ? model.label: model.id;
495 } 499 }
496 }) 500 })
497 501
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!