3045995a by Jerald Lim

remove models

1 parent 78963d5d
Showing 1 changed file with 12 additions and 22 deletions
...@@ -466,41 +466,31 @@ async function validation (aiwp_app_id, req, res) { ...@@ -466,41 +466,31 @@ async function validation (aiwp_app_id, req, res) {
466 466
467 // Get Models Route 467 // Get Models Route
468 app.get('/models', async (req, res) => { 468 app.get('/models', async (req, res) => {
469 const response = await openai.listModels(); 469 const openai_models = process.env.OPENAI_MODELS ? JSON.parse(process.env.OPENAI_MODELS) : [{"value": "gpt-3.5-turbo", "label": "GPT-3.5"}];
470 const models = response.data;
471 const opensource_models = process.env.OPENSOURCE_MODELS ? JSON.parse(process.env.OPENSOURCE_MODELS) : []; 470 const opensource_models = process.env.OPENSOURCE_MODELS ? JSON.parse(process.env.OPENSOURCE_MODELS) : [];
472 471
473 const excluded_models = process.env.EXCLUDED_MODELS ? String(process.env.EXCLUDED_MODELS).split(',') : []; 472 const models = {
473 data: []
474 };
474 475
475 models.data = models.data.filter((model) => { 476 openai_models.forEach((model) => {
476 return model.id.indexOf('gpt-3') === 0 && !excluded_models.includes(model.id) 477 models.data.push({
478 id: model.value,
479 label: model.label,
480 name: model.label,
481 beta: false,
482 });
477 }) 483 })
478 484
479 opensource_models.forEach((model) => { 485 opensource_models.forEach((model) => {
480 models.data.push({ 486 models.data.push({
481 id: model.value, 487 id: model.value,
482 label: model.label, 488 label: model.label,
489 name: model.label,
483 beta: true, 490 beta: true,
484 }); 491 });
485 }) 492 })
486 493
487
488 const months = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
489 // add name
490 models.data.forEach((model) => {
491 if (model.id.includes('gpt-3')) {
492 const d = new Date(model.created * 1000);
493 let month = months[d.getMonth()];
494 model.name = 'GPT-3.5 ' + month + ' ' + d.getDate();
495 } else if (model.id == 'dall-e-2') {
496 model.name = 'DALL-E 2';
497 } else if (model.id == 'dall-e-3') {
498 model.name = 'DALL-E 3';
499 } else {
500 model.name = model.label ? model.label: model.id;
501 }
502 })
503
504 res.json({ 494 res.json({
505 models 495 models
506 }) 496 })
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!