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) {
// Get Models Route
app.get('/models', async (req, res) => {
const response = await openai.listModels();
const models = response.data;
const openai_models = process.env.OPENAI_MODELS ? JSON.parse(process.env.OPENAI_MODELS) : [{"value": "gpt-3.5-turbo", "label": "GPT-3.5"}];
const opensource_models = process.env.OPENSOURCE_MODELS ? JSON.parse(process.env.OPENSOURCE_MODELS) : [];
const excluded_models = process.env.EXCLUDED_MODELS ? String(process.env.EXCLUDED_MODELS).split(',') : [];
const models = {
data: []
};
models.data = models.data.filter((model) => {
return model.id.indexOf('gpt-3') === 0 && !excluded_models.includes(model.id)
openai_models.forEach((model) => {
models.data.push({
id: model.value,
label: model.label,
name: model.label,
beta: false,
});
})
opensource_models.forEach((model) => {
models.data.push({
id: model.value,
label: model.label,
name: model.label,
beta: true,
});
})
const months = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
// add name
models.data.forEach((model) => {
if (model.id.includes('gpt-3')) {
const d = new Date(model.created * 1000);
let month = months[d.getMonth()];
model.name = 'GPT-3.5 ' + month + ' ' + d.getDate();
} else if (model.id == 'dall-e-2') {
model.name = 'DALL-E 2';
} else if (model.id == 'dall-e-3') {
model.name = 'DALL-E 3';
} else {
model.name = model.label ? model.label: model.id;
}
})
res.json({
models
})
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!