965e177a by Administrator

Merge branch '30033_open_ai_brand' into 'master'

30033_open_ai_brand

See merge request !95
2 parents 5c83a4ba d534360d
...@@ -33,7 +33,7 @@ const SideMenu = ({ ...@@ -33,7 +33,7 @@ const SideMenu = ({
33 {models && models.length ? ( 33 {models && models.length ? (
34 models.map((model, index) => ( 34 models.map((model, index) => (
35 <option key={model.id} value={model.id}> 35 <option key={model.id} value={model.id}>
36 {model.id} {model.beta ? "(beta)" : ""} 36 {model.name} {model.beta ? "(beta)" : ""}
37 </option> 37 </option>
38 )) 38 ))
39 ) : ( 39 ) : (
......
...@@ -250,15 +250,15 @@ async function runOpensource(req, res) { ...@@ -250,15 +250,15 @@ async function runOpensource(req, res) {
250 }, { 250 }, {
251 headers: { 251 headers: {
252 'Content-Type': 'application/json', 252 'Content-Type': 'application/json',
253 'Authorization': 'Bearer '+api_key 253 'Authorization': 'Bearer ' + api_key
254 }, 254 },
255 }) .catch(error => { 255 }).catch(error => {
256 error_msg = error.response.statusText ? error.response.statusText : ''; 256 error_msg = error.response.statusText ? error.response.statusText : '';
257 }); 257 });
258 258
259 if (error_msg!==''){ 259 if (error_msg !== '') {
260 input = "Error: "+error_msg; 260 input = "Error: " + error_msg;
261 }else{ 261 } else {
262 input = response.data.choices[0].message.content 262 input = response.data.choices[0].message.content
263 } 263 }
264 264
...@@ -302,12 +302,12 @@ async function runOpensource(req, res) { ...@@ -302,12 +302,12 @@ async function runOpensource(req, res) {
302 302
303 // Get Models Route 303 // Get Models Route
304 app.get('/models', async (req, res) => { 304 app.get('/models', async (req, res) => {
305 const response = await openai.listEngines(); 305 const response = await openai.listModels();
306 const models = response.data; 306 const models = response.data;
307 const opensource_models = process.env.OPENSOURCE_MODELS ? process.env.OPENSOURCE_MODELS.split(',') : []; 307 const opensource_models = process.env.OPENSOURCE_MODELS ? process.env.OPENSOURCE_MODELS.split(',') : [];
308 308
309 models.data = models.data.filter((model) => { 309 models.data = models.data.filter((model) => {
310 return model.id.indexOf('gpt-4') < 0 310 return model.id.indexOf('gpt-3') === 0
311 }) 311 })
312 312
313 opensource_models.forEach((model) => { 313 opensource_models.forEach((model) => {
...@@ -317,6 +317,23 @@ app.get('/models', async (req, res) => { ...@@ -317,6 +317,23 @@ app.get('/models', async (req, res) => {
317 }); 317 });
318 }) 318 })
319 319
320
321 const months = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
322 // add name
323 models.data.forEach((model) => {
324 if (model.id.includes('gpt-3')) {
325 const d = new Date(model.created * 1000);
326 let month = months[d.getMonth()];
327 model.name = 'GPT-3.5 ' + month + ' ' + d.getDate();
328 } else if (model.id == 'dall-e-2') {
329 model.name = 'DALL-E 2';
330 } else if (model.id == 'dall-e-3') {
331 model.name = 'DALL-E 3';
332 } else {
333 model.name = model.id;
334 }
335 })
336
320 res.json({ 337 res.json({
321 models 338 models
322 }) 339 })
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!