Skip to content

Commit

Permalink
fix: 稍微修改一下bing ws
Browse files Browse the repository at this point in the history
  • Loading branch information
ikechan8370 committed Jun 29, 2023
1 parent d4a3b2c commit 36e592e
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions utils/SydneyAIClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import HttpsProxyAgent from 'https-proxy-agent'
import { Config, pureSydneyInstruction } from './config.js'
import { formatDate, getMasterQQ, isCN, getUserData } from './common.js'
import delay from 'delay'
import moment from 'moment'

if (!globalThis.fetch) {
globalThis.fetch = fetch
Expand Down Expand Up @@ -309,7 +310,7 @@ export default class SydneyAIClient {
const text = (pureSydney ? pureSydneyInstruction : (useCast?.bing || Config.sydney)).replaceAll(namePlaceholder, botName || defaultBotName) +
((Config.enableGroupContext && groupId) ? groupContextTip : '') +
((Config.enforceMaster && master) ? masterTip : '') +
(Config.sydneyMood ? moodTip : '') +
(Config.sydneyMood ? moodTip : '') +
(Config.sydneySystemCode ? '' : '')
// logger.info(text)
if (pureSydney) {
Expand Down Expand Up @@ -373,16 +374,15 @@ export default class SydneyAIClient {
if (Config.enableGenerateContents) {
optionsSets.push(...['gencontentv3'])
}
const currentDate = moment().format('YYYY-MM-DDTHH:mm:ssZ')

const obj = {
arguments: [
{
source: 'cib',
optionsSets,
sliceIds: [
'222dtappid',
'225cricinfo',
'224locals0'
],
allowedMessageTypes: ['ActionRequest', 'Chat', 'Context', 'InternalSearchQuery', 'InternalSearchResult', 'Disengaged', 'InternalLoaderMessage', 'Progress', 'RenderCardRequest', 'AdsQuery', 'SemanticSerp', 'GenerateContentQuery', 'SearchQuery'],
sliceIds: [],
traceId: genRanHex(32),
isStartOfSession: invocationId === 0,
message: {
Expand Down Expand Up @@ -414,13 +414,17 @@ export default class SydneyAIClient {
author: 'user',
inputMethod: 'Keyboard',
text: message,
messageType
messageType,
userIpAddress: await generateRandomIP(),
timestamp: currentDate
// messageType: 'SearchQuery'
},
tone: 'Creative',
conversationSignature,
participant: {
id: clientId
},
spokenTextMode: 'None',
conversationId,
previousMessages
}
Expand Down Expand Up @@ -785,3 +789,16 @@ export default class SydneyAIClient {
return orderedMessages
}
}

async function generateRandomIP () {
let ip = await redis.get('CHATGPT:BING_IP')
if (ip) {
return ip
}
const baseIP = '104.28.215.'
const subnetSize = 254 // 2^8 - 2
const randomIPSuffix = Math.floor(Math.random() * subnetSize) + 1
ip = baseIP + randomIPSuffix
await redis.set('CHATGPT:BING_IP', ip, { EX: 86400 * 7 })
return ip
}

0 comments on commit 36e592e

Please sign in to comment.