mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
添加多必应token均衡支持 (#299)
This commit is contained in:
parent
7d89849c88
commit
8fb2615811
3 changed files with 100 additions and 132 deletions
27
apps/chat.js
27
apps/chat.js
|
|
@ -712,7 +712,8 @@ export class chatgpt extends plugin {
|
|||
parentMessageId: previousConversation.parentMessageId,
|
||||
clientId: previousConversation.clientId,
|
||||
invocationId: previousConversation.invocationId,
|
||||
conversationSignature: previousConversation.conversationSignature
|
||||
conversationSignature: previousConversation.conversationSignature,
|
||||
bingToken: previousConversation.bingToken
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -734,6 +735,7 @@ export class chatgpt extends plugin {
|
|||
previousConversation.invocationId = chatMessage.invocationId
|
||||
previousConversation.parentMessageId = chatMessage.parentMessageId
|
||||
previousConversation.conversationSignature = chatMessage.conversationSignature
|
||||
previousConversation.bingToken = chatMessage.bingToken
|
||||
} else {
|
||||
previousConversation.parentMessageId = chatMessage.id
|
||||
}
|
||||
|
|
@ -754,18 +756,7 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
// 分离内容和情绪
|
||||
if (Config.sydneyMood) {
|
||||
let temp_response = {}
|
||||
try {
|
||||
temp_response = JSON.parse(response)
|
||||
} catch (error) {
|
||||
// 尝试还原json格式
|
||||
try {
|
||||
temp_response = completeJSON(response)
|
||||
temp_response = JSON.parse(temp_response)
|
||||
} catch (error) {
|
||||
logger.error('数据格式错误', error)
|
||||
}
|
||||
}
|
||||
let temp_response = completeJSON(response)
|
||||
if (temp_response.text) response = temp_response.text
|
||||
if (temp_response.mood) mood = temp_response.mood
|
||||
} else {
|
||||
|
|
@ -1005,6 +996,13 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
case 'bing': {
|
||||
let bingToken = await redis.get('CHATGPT:BING_TOKEN')
|
||||
// 负载均衡
|
||||
if (!conversation.bingToken) {
|
||||
const bingTokens = bingToken.split('|')
|
||||
const select = Math.floor(Math.random() * bingTokens.length)
|
||||
bingToken = bingTokens[select]
|
||||
} else bingToken = conversation.bingToken
|
||||
|
||||
if (!bingToken) {
|
||||
throw new Error('未绑定Bing Cookie,请使用#chatgpt设置必应token命令绑定Bing Cookie')
|
||||
}
|
||||
|
|
@ -1121,7 +1119,8 @@ export class chatgpt extends plugin {
|
|||
clientId: response.clientId,
|
||||
invocationId: response.invocationId,
|
||||
conversationSignature: response.conversationSignature,
|
||||
parentMessageId: response.apology ? conversation.parentMessageId : response.messageId
|
||||
parentMessageId: response.apology ? conversation.parentMessageId : response.messageId,
|
||||
bingToken: bingToken
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue