去除bard

This commit is contained in:
zyc404 2024-05-08 15:42:35 +08:00
parent d111d2625e
commit 8efcce45a0
8 changed files with 4 additions and 517 deletions

View file

@ -3,8 +3,8 @@ import { Config } from '../utils/config.js'
import { KeyvFile } from 'keyv-file'
import _ from 'lodash'
export const originalValues = ['星火', '通义千问', '克劳德', '克劳德2', '必应', 'api', 'API', 'api3', 'API3', 'glm', '巴德', '双子星', '双子座', '智谱']
export const correspondingValues = ['xh', 'qwen', 'claude', 'claude2', 'bing', 'api', 'api', 'api3', 'api3', 'chatglm', 'bard', 'gemini', 'gemini', 'chatglm4']
export const originalValues = ['星火', '通义千问', '克劳德', '克劳德2', '必应', 'api', 'API', 'api3', 'API3', 'glm', '双子星', '双子座', '智谱']
export const correspondingValues = ['xh', 'qwen', 'claude', 'claude2', 'bing', 'api', 'api', 'api3', 'api3', 'chatglm', 'gemini', 'gemini', 'chatglm4']
export class ConversationManager {
async endConversation (e) {
@ -35,11 +35,6 @@ export class ConversationManager {
await this.reply('星火对话已结束')
return
}
if (use === 'bard') {
await redis.del(`CHATGPT:CONVERSATIONS_BARD:${(e.isGroup && Config.groupMerge) ? e.group_id.toString() : e.sender.user_id}`)
await this.reply('Bard对话已结束')
return
}
let ats = e.message.filter(m => m.type === 'at')
const isAtMode = Config.toggleMode === 'at'
if (isAtMode) ats = ats.filter(item => item.qq !== getUin(e))
@ -259,17 +254,6 @@ export class ConversationManager {
}
break
}
case 'bard': {
let cs = await redis.keys('CHATGPT:CONVERSATIONS_BARD:*')
for (let i = 0; i < cs.length; i++) {
await redis.del(cs[i])
if (Config.debug) {
logger.info('delete bard conversation of qq: ' + cs[i])
}
deleted++
}
break
}
case 'bing': {
let cs = await redis.keys('CHATGPT:CONVERSATIONS_BING:*')
let we = await redis.keys('CHATGPT:WRONG_EMOTION:*')

View file

@ -25,7 +25,6 @@ import XinghuoClient from '../utils/xinghuo/xinghuo.js'
import { getMessageById, upsertMessage } from '../utils/history.js'
import { v4 as uuid } from 'uuid'
import fetch from 'node-fetch'
import Bard from '../utils/bard.js'
import { CustomGoogleGeminiClient } from '../client/CustomGoogleGeminiClient.js'
import { resizeAndCropImage } from '../utils/dalle.js'
import fs from 'fs'
@ -706,55 +705,6 @@ class Core {
}
return msg
}
} else if (use === 'bard') {
// 处理cookie
const matchesPSID = /__Secure-1PSID=([^;]+)/.exec(Config.bardPsid)
const matchesPSIDTS = /__Secure-1PSIDTS=([^;]+)/.exec(Config.bardPsid)
const cookie = {
'__Secure-1PSID': matchesPSID[1],
'__Secure-1PSIDTS': matchesPSIDTS[1]
}
if (!matchesPSID[1] || !matchesPSIDTS[1]) {
throw new Error('未绑定bard')
}
// 处理图片
const image = await getImg(e)
let imageBuff
if (image) {
try {
let imgResponse = await fetch(image[0])
if (imgResponse.ok) {
imageBuff = await imgResponse.arrayBuffer()
}
} catch (error) {
logger.warn(`错误的图片链接${image[0]}`)
}
}
// 发送数据
let bot = new Bard(cookie, {
fetch,
bardURL: Config.bardForceUseReverse ? Config.bardReverseProxy : 'https://bard.google.com'
})
let chat = await bot.createChat(conversation?.conversationId
? {
conversationID: conversation.conversationId,
responseID: conversation.parentMessageId,
choiceID: conversation.clientId,
_reqID: conversation.invocationId
}
: {})
let response = await chat.ask(prompt, {
image: imageBuff,
format: Bard.JSON
})
return {
conversationId: response.ids.conversationID,
responseID: response.ids.responseID,
choiceID: response.ids.choiceID,
_reqID: response.ids._reqID,
text: response.content,
images: response.images
}
} else if (use === 'gemini') {
let client = new CustomGoogleGeminiClient({
e,