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) {
// 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) : [];
models.data = models.data.filter((model) => {
return model.id.indexOf('gpt-3') === 0
const models = {
data: []
};
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!