Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -53,21 +53,20 @@ puppeteer.use(StealthPlugin())
|
|
| 53 |
|
| 54 |
// 请求头配置
|
| 55 |
const DEFAULT_HEADERS = {
|
| 56 |
-
'
|
| 57 |
-
'
|
| 58 |
-
'
|
| 59 |
-
'
|
| 60 |
'Connection': 'keep-alive',
|
| 61 |
-
'
|
| 62 |
-
'
|
| 63 |
-
'
|
| 64 |
-
'
|
| 65 |
-
'
|
| 66 |
-
'
|
| 67 |
-
'
|
| 68 |
-
'
|
| 69 |
-
'
|
| 70 |
-
'baggage': 'sentry-public_key=b311e0f2690c81f25e2c4cf6d4f7ce1c'
|
| 71 |
};
|
| 72 |
|
| 73 |
|
|
@@ -95,7 +94,7 @@ async function initialization() {
|
|
| 95 |
);
|
| 96 |
|
| 97 |
await Promise.all(batchPromises);
|
| 98 |
-
Logger.info(`已加载令牌: ${i} 个`, 'Server');
|
| 99 |
await new Promise(resolve => setTimeout(resolve, 1000));
|
| 100 |
}
|
| 101 |
Logger.info(`令牌加载完成: ${JSON.stringify(tokenManager.getAllTokens(), null, 2)}`, 'Server');
|
|
@@ -1203,11 +1202,8 @@ app.post('/hf/v1/chat/completions', async (req, res) => {
|
|
| 1203 |
const response = await fetch(`${CONFIG.API.BASE_URL}/rest/app-chat/conversations/new`, {
|
| 1204 |
method: 'POST',
|
| 1205 |
headers: {
|
| 1206 |
-
|
| 1207 |
-
"
|
| 1208 |
-
"content-type": "text/plain;charset=UTF-8",
|
| 1209 |
-
"Connection": "keep-alive",
|
| 1210 |
-
"cookie": CONFIG.API.SIGNATURE_COOKIE
|
| 1211 |
},
|
| 1212 |
body: JSON.stringify(requestPayload)
|
| 1213 |
});
|
|
|
|
| 53 |
|
| 54 |
// 请求头配置
|
| 55 |
const DEFAULT_HEADERS = {
|
| 56 |
+
'Accept': '*/*',
|
| 57 |
+
'Accept-Language': 'zh-CN,zh;q=0.9',
|
| 58 |
+
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
| 59 |
+
'Content-Type': 'text/plain;charset=UTF-8',
|
| 60 |
'Connection': 'keep-alive',
|
| 61 |
+
'Origin': 'https://grok.com',
|
| 62 |
+
'Priority': 'u=1, i',
|
| 63 |
+
'Sec-Ch-Ua': '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
|
| 64 |
+
'Sec-Ch-Ua-Mobile': '?0',
|
| 65 |
+
'Sec-Ch-Ua-Platform': '"Windows"',
|
| 66 |
+
'Sec-Fetch-Dest': 'empty',
|
| 67 |
+
'Sec-Fetch-Mode': 'cors',
|
| 68 |
+
'Sec-Fetch-Site': 'same-origin',
|
| 69 |
+
'Baggage': 'sentry-public_key=b311e0f2690c81f25e2c4cf6d4f7ce1c'
|
|
|
|
| 70 |
};
|
| 71 |
|
| 72 |
|
|
|
|
| 94 |
);
|
| 95 |
|
| 96 |
await Promise.all(batchPromises);
|
| 97 |
+
Logger.info(`已加载令牌: ${i+1} 个`, 'Server');
|
| 98 |
await new Promise(resolve => setTimeout(resolve, 1000));
|
| 99 |
}
|
| 100 |
Logger.info(`令牌加载完成: ${JSON.stringify(tokenManager.getAllTokens(), null, 2)}`, 'Server');
|
|
|
|
| 1202 |
const response = await fetch(`${CONFIG.API.BASE_URL}/rest/app-chat/conversations/new`, {
|
| 1203 |
method: 'POST',
|
| 1204 |
headers: {
|
| 1205 |
+
...DEFAULT_HEADERS,
|
| 1206 |
+
"Cookie": CONFIG.API.SIGNATURE_COOKIE
|
|
|
|
|
|
|
|
|
|
| 1207 |
},
|
| 1208 |
body: JSON.stringify(requestPayload)
|
| 1209 |
});
|