Update bym.js (#735)

* feat: new bing (WIP)

* fix: update CopilotAIClient.js

* fix: gemini强制调用tool;real at

* feat: add bym support
This commit is contained in:
ikechan8370 2024-12-29 19:57:55 +08:00 committed by GitHub
parent 5f6c4e5abb
commit 26444df2a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 599 additions and 30 deletions

View file

@ -95,27 +95,27 @@ export default class SydneyAIClient {
fetchOptions.headers.cookie = this.opts.cookies
}
// let hash = md5(this.opts.cookies || this.opts.userToken)
let hash = crypto.createHash('md5').update(this.opts.cookies || this.opts.userToken).digest('hex')
let proTag = await redis.get('CHATGPT:COPILOT_PRO_TAG:' + hash)
if (!proTag) {
let indexContentRes = await fetch('https://www.bing.com/chat', {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0',
Cookie: `_U=${this.opts.userToken}`
}
})
let indexContent = await indexContentRes.text()
if (indexContent?.includes('b_proTag')) {
proTag = 'true'
} else {
proTag = 'false'
}
await redis.set('CHATGPT:COPILOT_PRO_TAG:' + hash, proTag, { EX: 7200 })
}
if (proTag === 'true') {
logger.info('当前账户为copilot pro用户')
this.pro = true
}
// let hash = crypto.createHash('md5').update(this.opts.cookies || this.opts.userToken).digest('hex')
// let proTag = await redis.get('CHATGPT:COPILOT_PRO_TAG:' + hash)
// if (!proTag) {
// let indexContentRes = await fetch('https://www.bing.com/chat', {
// headers: {
// 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0',
// Cookie: `_U=${this.opts.userToken}`
// }
// })
// let indexContent = await indexContentRes.text()
// if (indexContent?.includes('b_proTag')) {
// proTag = 'true'
// } else {
// proTag = 'false'
// }
// await redis.set('CHATGPT:COPILOT_PRO_TAG:' + hash, proTag, { EX: 7200 })
// }
// if (proTag === 'true') {
// logger.info('当前账户为copilot pro用户')
// this.pro = true
// }
} else {
fetchOptions.headers.cookie = initCk
}