Update app.js
Browse files
app.js
CHANGED
@@ -147,6 +147,25 @@ app.get('/', (req, res) => {
|
|
147 |
});
|
148 |
});
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
app.post('/ai/v1/chat/completions', async (req, res) => {
|
151 |
const startTime = new Date();
|
152 |
const clientIP = req.ip || req.connection.remoteAddress;
|
|
|
147 |
});
|
148 |
});
|
149 |
|
150 |
+
app.post('/ai/v1/models', (req, res) => {
|
151 |
+
const authHeader = req.headers['authorization'];
|
152 |
+
if (!authHeader || !authHeader.startsWith('Bearer ') || authHeader.slice(7) !== AUTH_KEY) {
|
153 |
+
return res.status(401).json({ error: 'Unauthorized' });
|
154 |
+
}
|
155 |
+
|
156 |
+
res.json({
|
157 |
+
object: "list",
|
158 |
+
data: Object.keys(MODEL_MAPPING).map(model => ({
|
159 |
+
id: model,
|
160 |
+
object: "model",
|
161 |
+
created: Math.floor(Date.now() / 1000),
|
162 |
+
owned_by: "notdiamond"
|
163 |
+
}))
|
164 |
+
});
|
165 |
+
|
166 |
+
console.log(`${new Date().toISOString()} - ${req.ip || req.connection.remoteAddress} - /ai/v1/models - 200`);
|
167 |
+
});
|
168 |
+
|
169 |
app.post('/ai/v1/chat/completions', async (req, res) => {
|
170 |
const startTime = new Date();
|
171 |
const clientIP = req.ip || req.connection.remoteAddress;
|