00d21dfc by Jerald Lim

30033_open_ai_brand

1 parent 56e92779
......@@ -33,7 +33,7 @@ const SideMenu = ({
{models && models.length ? (
models.map((model, index) => (
<option key={model.id} value={model.id}>
{model.id} {model.beta ? "(beta)" : ""}
{model.name} {model.beta ? "(beta)" : ""}
</option>
))
) : (
......
......@@ -250,15 +250,15 @@ async function runOpensource(req, res) {
}, {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer '+api_key
'Authorization': 'Bearer ' + api_key
},
}) .catch(error => {
}).catch(error => {
error_msg = error.response.statusText ? error.response.statusText : '';
});
if (error_msg!==''){
input = "Error: "+error_msg;
}else{
if (error_msg !== '') {
input = "Error: " + error_msg;
} else {
input = response.data.choices[0].message.content
}
......@@ -302,12 +302,12 @@ async function runOpensource(req, res) {
// Get Models Route
app.get('/models', async (req, res) => {
const response = await openai.listEngines();
const response = await openai.listModels();
const models = response.data;
const opensource_models = process.env.OPENSOURCE_MODELS ? process.env.OPENSOURCE_MODELS.split(',') : [];
models.data = models.data.filter((model) => {
return model.id.indexOf('gpt-4') < 0
return model.id.indexOf('gpt-3') === 0
})
opensource_models.forEach((model) => {
......@@ -317,6 +317,23 @@ app.get('/models', async (req, res) => {
});
})
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 ' + 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.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!