Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
@@ -52,7 +52,7 @@ const DEFAULT_HEADERS = {
|
|
52 |
'sec-fetch-dest': 'empty',
|
53 |
'sec-fetch-mode': 'cors',
|
54 |
'sec-fetch-site': 'same-origin',
|
55 |
-
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)
|
56 |
'baggage': 'sentry-public_key=b311e0f2690c81f25e2c4cf6d4f7ce1c'
|
57 |
};
|
58 |
// Add this class for managing authentication state
|
@@ -480,7 +480,7 @@ app.use(cors({
|
|
480 |
allowedHeaders: ['Content-Type', 'Authorization']
|
481 |
}));
|
482 |
// API路由
|
483 |
-
app.get('/v1/models', (req, res) => {
|
484 |
res.json({
|
485 |
object: "list",
|
486 |
data: Object.keys(CONFIG.MODELS).map((model, index) => ({
|
@@ -492,7 +492,7 @@ app.get('/v1/models', (req, res) => {
|
|
492 |
});
|
493 |
});
|
494 |
|
495 |
-
app.post('/v1/chat/completions', async (req, res) => {
|
496 |
const authToken = req.headers.authorization?.replace('Bearer ', '');
|
497 |
console.log(authToken);
|
498 |
if (authToken !== CONFIG.API.API_KEY) {
|
|
|
52 |
'sec-fetch-dest': 'empty',
|
53 |
'sec-fetch-mode': 'cors',
|
54 |
'sec-fetch-site': 'same-origin',
|
55 |
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Apple网页Kit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
|
56 |
'baggage': 'sentry-public_key=b311e0f2690c81f25e2c4cf6d4f7ce1c'
|
57 |
};
|
58 |
// Add this class for managing authentication state
|
|
|
480 |
allowedHeaders: ['Content-Type', 'Authorization']
|
481 |
}));
|
482 |
// API路由
|
483 |
+
app.get('/hf/v1/models', (req, res) => {
|
484 |
res.json({
|
485 |
object: "list",
|
486 |
data: Object.keys(CONFIG.MODELS).map((model, index) => ({
|
|
|
492 |
});
|
493 |
});
|
494 |
|
495 |
+
app.post('/hf/v1/chat/completions', async (req, res) => {
|
496 |
const authToken = req.headers.authorization?.replace('Bearer ', '');
|
497 |
console.log(authToken);
|
498 |
if (authToken !== CONFIG.API.API_KEY) {
|