Upload 6 files
Browse files- src/index.js +37 -2
src/index.js
CHANGED
|
@@ -7,10 +7,45 @@ const app = express();
|
|
| 7 |
app.use(express.json());
|
| 8 |
app.use(express.urlencoded({ extended: true }));
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
// Models starting with o1 do not support streaming output
|
| 12 |
if (req.body.model.startsWith('o1-') && req.body.stream) {
|
| 13 |
-
delete req.body.stream;
|
| 14 |
}
|
| 15 |
|
| 16 |
let currentKeyIndex = 0;
|
|
|
|
| 7 |
app.use(express.json());
|
| 8 |
app.use(express.urlencoded({ extended: true }));
|
| 9 |
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
const availableModels = [
|
| 13 |
+
'claude-3-5-sonnet-20241022',
|
| 14 |
+
'claude-3-opus',
|
| 15 |
+
'claude-3.5-haiku',
|
| 16 |
+
'claude-3.5-sonnet',
|
| 17 |
+
'cursor-small',
|
| 18 |
+
'gpt-3.5-turbo',
|
| 19 |
+
'gpt-4',
|
| 20 |
+
'gpt-4-turbo-2024-04-09',
|
| 21 |
+
'gpt-4o',
|
| 22 |
+
'gpt-4o-mini',
|
| 23 |
+
'o1-mini',
|
| 24 |
+
'o1-preview',
|
| 25 |
+
];
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
app.get('/api/v1/models', (req, res) => {
|
| 29 |
+
const currentTime = Math.floor(Date.now() / 1000);
|
| 30 |
+
const modelData = availableModels.map(model => ({
|
| 31 |
+
id: model,
|
| 32 |
+
object: 'model',
|
| 33 |
+
created: currentTime,
|
| 34 |
+
owned_by: 'cursor',
|
| 35 |
+
}));
|
| 36 |
+
|
| 37 |
+
const responseData = {
|
| 38 |
+
object: 'list',
|
| 39 |
+
data: modelData,
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
res.json(responseData);
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
app.post('/api/v1/chat/completions', async (req, res) => {
|
| 46 |
// Models starting with o1 do not support streaming output
|
| 47 |
if (req.body.model.startsWith('o1-') && req.body.stream) {
|
| 48 |
+
delete req.body.stream; // просто блять удали стримминг тупая тварь, а не вываливай ошибку заставляя меня отключать вручную, безмозглая ущкоглазая обезьяна!!1
|
| 49 |
}
|
| 50 |
|
| 51 |
let currentKeyIndex = 0;
|