d4d3f808 by Administrator

Merge branch '31608_remove_deprecated_models' into 'master'

31608_remove_deprecated_models

See merge request !114
2 parents 85160124 3045995a
Pipeline #29668 for d4d3f808 passed in 16 seconds
Showing 1 changed file with 13 additions and 21 deletions
...@@ -475,39 +475,31 @@ async function validation (aiwp_app_id, req, res) { ...@@ -475,39 +475,31 @@ async function validation (aiwp_app_id, req, res) {
475 475
476 // Get Models Route 476 // Get Models Route
477 app.get('/models', async (req, res) => { 477 app.get('/models', async (req, res) => {
478 const response = await openai.listModels(); 478 const openai_models = process.env.OPENAI_MODELS ? JSON.parse(process.env.OPENAI_MODELS) : [{"value": "gpt-3.5-turbo", "label": "GPT-3.5"}];
479 const models = response.data;
480 const opensource_models = process.env.OPENSOURCE_MODELS ? JSON.parse(process.env.OPENSOURCE_MODELS) : []; 479 const opensource_models = process.env.OPENSOURCE_MODELS ? JSON.parse(process.env.OPENSOURCE_MODELS) : [];
481 480
482 models.data = models.data.filter((model) => { 481 const models = {
483 return model.id.indexOf('gpt-3') === 0 482 data: []
483 };
484
485 openai_models.forEach((model) => {
486 models.data.push({
487 id: model.value,
488 label: model.label,
489 name: model.label,
490 beta: false,
491 });
484 }) 492 })
485 493
486 opensource_models.forEach((model) => { 494 opensource_models.forEach((model) => {
487 models.data.push({ 495 models.data.push({
488 id: model.value, 496 id: model.value,
489 label: model.label, 497 label: model.label,
498 name: model.label,
490 beta: true, 499 beta: true,
491 }); 500 });
492 }) 501 })
493 502
494
495 const months = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
496 // add name
497 models.data.forEach((model) => {
498 if (model.id.includes('gpt-3')) {
499 const d = new Date(model.created * 1000);
500 let month = months[d.getMonth()];
501 model.name = 'GPT-3.5 ' + month + ' ' + d.getDate();
502 } else if (model.id == 'dall-e-2') {
503 model.name = 'DALL-E 2';
504 } else if (model.id == 'dall-e-3') {
505 model.name = 'DALL-E 3';
506 } else {
507 model.name = model.label ? model.label: model.id;
508 }
509 })
510
511 res.json({ 503 res.json({
512 models 504 models
513 }) 505 })
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!