smgc commited on
Commit
97f1d5d
1 Parent(s): b86a41e

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +26 -0
app.js CHANGED
@@ -247,6 +247,32 @@ app.get('/', (req, res) => {
247
  });
248
  });
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  app.post('/ai/v1/chat/completions', async (req, res) => {
251
  const startTime = new Date();
252
  const clientIP = req.ip || req.connection.remoteAddress;
 
247
  });
248
  });
249
 
250
+ app.get('/ai/v1/models', async (req, res) => {
251
+ try {
252
+ const authCookie = await getAuthCookie(req);
253
+ if (!authCookie) {
254
+ return res.status(401).json({ error: 'Unauthorized' });
255
+ }
256
+
257
+ res.json({
258
+ object: "list",
259
+ data: Object.entries(MODEL_MAPPING).map(([id, info]) => ({
260
+ id: id,
261
+ object: "model",
262
+ created: Math.floor(Date.now() / 1000),
263
+ owned_by: info.provider,
264
+ permission: [],
265
+ root: id,
266
+ parent: null,
267
+ }))
268
+ });
269
+
270
+ console.log(`${new Date().toISOString()} - ${req.ip || req.connection.remoteAddress} - GET /ai/v1/models - 200`);
271
+ } catch (error) {
272
+ res.status(401).json({ error: 'Authentication failed', details: error.message });
273
+ }
274
+ });
275
+
276
  app.post('/ai/v1/chat/completions', async (req, res) => {
277
  const startTime = new Date();
278
  const clientIP = req.ip || req.connection.remoteAddress;