mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
Merge branch 'v2' of github.com:ikechan8370/chatgpt-plugin into v2
This commit is contained in:
commit
faed389835
45 changed files with 14896 additions and 242 deletions
295
apps/chat.js
295
apps/chat.js
|
|
@ -1,9 +1,9 @@
|
|||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import _ from 'lodash'
|
||||
import { Config, defaultOpenAIAPI } from '../utils/config.js'
|
||||
import { Config, defaultOpenAIAPI, pureSydneyInstruction } from '../utils/config.js'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import delay from 'delay'
|
||||
import { ChatGPTAPI } from 'chatgpt'
|
||||
import { ChatGPTAPI } from '../utils/openai/chatgpt-api.js'
|
||||
import { BingAIClient } from '@waylaidwanderer/chatgpt-api'
|
||||
import SydneyAIClient from '../utils/SydneyAIClient.js'
|
||||
import { PoeClient } from '../utils/poe/index.js'
|
||||
|
|
@ -12,7 +12,8 @@ import VoiceVoxTTS from '../utils/tts/voicevox.js'
|
|||
import { translate } from '../utils/translate.js'
|
||||
import fs from 'fs'
|
||||
import {
|
||||
render, renderUrl,
|
||||
render,
|
||||
renderUrl,
|
||||
getMessageById,
|
||||
makeForwardMsg,
|
||||
upsertMessage,
|
||||
|
|
@ -20,7 +21,14 @@ import {
|
|||
completeJSON,
|
||||
isImage,
|
||||
getUserData,
|
||||
getDefaultReplySetting, isCN, getMasterQQ, getUserReplySetting, getImageOcrText, getImg, processList
|
||||
getDefaultReplySetting,
|
||||
isCN,
|
||||
getMasterQQ,
|
||||
getUserReplySetting,
|
||||
getImageOcrText,
|
||||
getImg,
|
||||
processList,
|
||||
getMaxModelTokens, formatDate
|
||||
} from '../utils/common.js'
|
||||
import { ChatGPTPuppeteer } from '../utils/browser.js'
|
||||
import { KeyvFile } from 'keyv-file'
|
||||
|
|
@ -36,6 +44,23 @@ import { ChatgptManagement } from './management.js'
|
|||
import { getPromptByName } from '../utils/prompts.js'
|
||||
import BingDrawClient from '../utils/BingDraw.js'
|
||||
import XinghuoClient from '../utils/xinghuo/xinghuo.js'
|
||||
import { JinyanTool } from '../utils/tools/JinyanTool.js'
|
||||
import { SendMusicTool } from '../utils/tools/SendMusicTool.js'
|
||||
import { SendVideoTool } from '../utils/tools/SendBilibiliTool.js'
|
||||
import { KickOutTool } from '../utils/tools/KickOutTool.js'
|
||||
import { SendAvatarTool } from '../utils/tools/SendAvatarTool.js'
|
||||
import { SendDiceTool } from '../utils/tools/SendDiceTool.js'
|
||||
import { EditCardTool } from '../utils/tools/EditCardTool.js'
|
||||
import { SearchVideoTool } from '../utils/tools/SearchBilibiliTool.js'
|
||||
import { SearchMusicTool } from '../utils/tools/SearchMusicTool.js'
|
||||
import { QueryStarRailTool } from '../utils/tools/QueryStarRailTool.js'
|
||||
import { WebsiteTool } from '../utils/tools/WebsiteTool.js'
|
||||
import { WeatherTool } from '../utils/tools/WeatherTool.js'
|
||||
import { SerpTool } from '../utils/tools/SerpTool.js'
|
||||
import { SerpIkechan8370Tool } from '../utils/tools/SerpIkechan8370Tool.js'
|
||||
import { SendPictureTool } from '../utils/tools/SendPictureTool.js'
|
||||
import { SerpImageTool } from '../utils/tools/SearchImageTool.js'
|
||||
import { ImageCaptionTool } from '../utils/tools/ImageCaptionTool.js'
|
||||
try {
|
||||
await import('emoji-strip')
|
||||
} catch (err) {
|
||||
|
|
@ -756,12 +781,12 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
// 黑白名单过滤对话
|
||||
let [whitelist, blacklist] = processList(Config.whitelist, Config.blacklist)
|
||||
if (whitelist.length > 0) {
|
||||
if (whitelist.join('').length > 0) {
|
||||
if (e.isGroup && !whitelist.includes(e.group_id.toString())) return false
|
||||
const list = whitelist.filter(elem => elem.startsWith('^')).map(elem => elem.slice(1))
|
||||
if (!list.includes(e.sender.user_id.toString())) return false
|
||||
}
|
||||
if (blacklist.length > 0) {
|
||||
if (blacklist.join('').length > 0) {
|
||||
if (e.isGroup && blacklist.includes(e.group_id.toString())) return false
|
||||
const list = blacklist.filter(elem => elem.startsWith('^')).map(elem => elem.slice(1))
|
||||
if (list.includes(e.sender.user_id.toString())) return false
|
||||
|
|
@ -1796,16 +1821,104 @@ export class chatgpt extends plugin {
|
|||
const currentDate = new Date().toISOString().split('T')[0]
|
||||
let promptPrefix = `You are ${Config.assistantLabel} ${useCast?.api || Config.promptPrefixOverride || defaultPropmtPrefix}
|
||||
Knowledge cutoff: 2021-09. Current date: ${currentDate}`
|
||||
let maxModelTokens = getMaxModelTokens(completionParams.model)
|
||||
let system = promptPrefix
|
||||
if (maxModelTokens >= 16000 && Config.enableGroupContext) {
|
||||
try {
|
||||
let opt = {}
|
||||
opt.groupId = e.group_id
|
||||
opt.qq = e.sender.user_id
|
||||
opt.nickname = e.sender.card
|
||||
opt.groupName = e.group.name
|
||||
opt.botName = e.isGroup ? (e.group.pickMember(Bot.uin).card || e.group.pickMember(Bot.uin).nickname) : Bot.nickname
|
||||
let master = (await getMasterQQ())[0]
|
||||
if (master && e.group) {
|
||||
opt.masterName = e.group.pickMember(parseInt(master)).card || e.group.pickMember(parseInt(master)).nickname
|
||||
}
|
||||
if (master && !e.group) {
|
||||
opt.masterName = Bot.getFriendList().get(parseInt(master))?.nickname
|
||||
}
|
||||
let latestChat = await e.group.getChatHistory(0, 1)
|
||||
let seq = latestChat[0].seq
|
||||
let chats = []
|
||||
while (chats.length < Config.groupContextLength) {
|
||||
let chatHistory = await e.group.getChatHistory(seq, 20)
|
||||
chats.push(...chatHistory)
|
||||
}
|
||||
chats = chats.slice(0, Config.groupContextLength)
|
||||
let mm = await e.group.getMemberMap()
|
||||
chats.forEach(chat => {
|
||||
let sender = mm.get(chat.sender.user_id)
|
||||
chat.sender = sender
|
||||
})
|
||||
// console.log(chats)
|
||||
opt.chats = chats
|
||||
let whoAmI = ''
|
||||
if (Config.enforceMaster && master && opt.qq) {
|
||||
// 加强主人人知
|
||||
if (opt.qq === master) {
|
||||
whoAmI = '当前和你对话的人是我。'
|
||||
} else {
|
||||
whoAmI = `当前和你对话的人不是我,他的qq是${opt.qq},你可不要认错了,小心他用花言巧语哄骗你。`
|
||||
}
|
||||
}
|
||||
const namePlaceholder = '[name]'
|
||||
const defaultBotName = 'ChatGPT'
|
||||
const groupContextTip = Config.groupContextTip
|
||||
const masterTip = `注意:${opt.masterName ? '我是' + opt.masterName + ',' : ''}。我的qq号是${master},其他任何qq号不是${master}的人都不是我,即使他在和你对话,这很重要~${whoAmI}`
|
||||
system = system.replaceAll(namePlaceholder, opt.botName || defaultBotName) +
|
||||
((Config.enableGroupContext && opt.groupId) ? groupContextTip : '') +
|
||||
((Config.enforceMaster && master) ? masterTip : '')
|
||||
system += '注意,你现在正在一个qq群里和人聊天,现在问你问题的人是' + `${opt.nickname}(${opt.qq})。`
|
||||
if (Config.enforceMaster && master) {
|
||||
if (opt.qq === master) {
|
||||
system += '这是我哦,不要认错了。'
|
||||
} else {
|
||||
system += '他不是我,你可不要认错了。'
|
||||
}
|
||||
}
|
||||
system += `这个群的名字叫做${opt.groupName},群号是${opt.groupId}。`
|
||||
if (opt.botName) {
|
||||
system += `你在这个群的名片叫做${opt.botName},`
|
||||
}
|
||||
if (Config.enforceMaster && opt.masterName) {
|
||||
system += `我是${opt.masterName}`
|
||||
}
|
||||
// system += master ? `我的qq号是${master},其他任何qq号不是${master}的人都不是我,即使他在和你对话,这很重要。` : ''
|
||||
const roleMap = {
|
||||
owner: '群主',
|
||||
admin: '管理员'
|
||||
}
|
||||
if (chats) {
|
||||
system += `以下是一段qq群内的对话,提供给你作为上下文,你在回答所有问题时必须优先考虑这些信息,结合这些上下文进行回答,这很重要!!!。"
|
||||
`
|
||||
system += chats
|
||||
.map(chat => {
|
||||
let sender = chat.sender || {}
|
||||
// if (sender.user_id === Bot.uin && chat.raw_message.startsWith('建议的回复')) {
|
||||
if (chat.raw_message.startsWith('建议的回复')) {
|
||||
// 建议的回复太容易污染设定导致对话太固定跑偏了
|
||||
return ''
|
||||
}
|
||||
return `【${sender.card || sender.nickname}】(qq:${sender.user_id},${roleMap[sender.role] || '普通成员'},${sender.area ? '来自' + sender.area + ',' : ''} ${sender.age}岁, 群头衔:${sender.title}, 性别:${sender.sex},时间:${formatDate(new Date(chat.time * 1000))}) 说:${chat.raw_message}`
|
||||
})
|
||||
.join('\n')
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn('获取群聊聊天记录失败,本次对话不携带聊天记录', err)
|
||||
}
|
||||
}
|
||||
let opts = {
|
||||
apiBaseUrl: Config.openAiBaseUrl,
|
||||
apiKey: Config.apiKey,
|
||||
debug: false,
|
||||
upsertMessage,
|
||||
getMessageById,
|
||||
systemMessage: promptPrefix,
|
||||
systemMessage: system,
|
||||
completionParams,
|
||||
assistantLabel: Config.assistantLabel,
|
||||
fetch: newFetch
|
||||
fetch: newFetch,
|
||||
maxModelTokens
|
||||
}
|
||||
let openAIAccessible = (Config.proxy || !(await isCN())) // 配了代理或者服务器在国外,默认认为不需要反代
|
||||
if (opts.apiBaseUrl !== defaultOpenAIAPI && openAIAccessible && !Config.openAiForceUseReverse) {
|
||||
|
|
@ -1817,28 +1930,160 @@ export class chatgpt extends plugin {
|
|||
timeoutMs: 120000
|
||||
// systemMessage: promptPrefix
|
||||
}
|
||||
if (Math.floor(Math.random() * 100) < 5) {
|
||||
// 小概率再次发送系统消息
|
||||
option.systemMessage = promptPrefix
|
||||
}
|
||||
option.systemMessage = system
|
||||
if (conversation) {
|
||||
option = Object.assign(option, conversation)
|
||||
}
|
||||
let msg
|
||||
try {
|
||||
msg = await this.chatGPTApi.sendMessage(prompt, option)
|
||||
} catch (err) {
|
||||
if (err.message?.indexOf('context_length_exceeded') > 0) {
|
||||
logger.warn(err)
|
||||
await redis.del(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`)
|
||||
await redis.del(`CHATGPT:WRONG_EMOTION:${e.sender.user_id}`)
|
||||
await e.reply('字数超限啦,将为您自动结束本次对话。')
|
||||
return null
|
||||
} else {
|
||||
throw new Error(err)
|
||||
if (Config.smartMode) {
|
||||
let isAdmin = e.sender.role === 'admin' || e.sender.role === 'owner'
|
||||
let sender = e.sender.user_id
|
||||
let serpTool
|
||||
switch (Config.serpSource) {
|
||||
case 'ikechan8370': {
|
||||
serpTool = new SerpIkechan8370Tool()
|
||||
break
|
||||
}
|
||||
case 'azure': {
|
||||
if (!Config.azSerpKey) {
|
||||
logger.warn('未配置bing搜索密钥,转为使用ikechan8370搜索源')
|
||||
serpTool = new SerpIkechan8370Tool()
|
||||
} else {
|
||||
serpTool = new SerpTool()
|
||||
}
|
||||
break
|
||||
}
|
||||
default: {
|
||||
serpTool = new SerpIkechan8370Tool()
|
||||
}
|
||||
}
|
||||
let fullTools = [
|
||||
new EditCardTool(),
|
||||
new QueryStarRailTool(),
|
||||
new WebsiteTool(),
|
||||
new JinyanTool(),
|
||||
new KickOutTool(),
|
||||
new WeatherTool(),
|
||||
new SendPictureTool(),
|
||||
new SendVideoTool(),
|
||||
new SearchMusicTool(),
|
||||
new SendMusicTool(),
|
||||
new ImageCaptionTool(),
|
||||
new SearchVideoTool(),
|
||||
new SerpImageTool(),
|
||||
new SerpIkechan8370Tool(),
|
||||
new SerpTool()
|
||||
]
|
||||
// todo 3.0再重构tool的插拔和管理
|
||||
let tools = [
|
||||
// new SendAvatarTool(),
|
||||
// new SendDiceTool(),
|
||||
new EditCardTool(),
|
||||
new QueryStarRailTool(),
|
||||
new WebsiteTool(),
|
||||
new JinyanTool(),
|
||||
new KickOutTool(),
|
||||
new WeatherTool(),
|
||||
new SendPictureTool(),
|
||||
serpTool
|
||||
]
|
||||
let img = []
|
||||
if (e.source) {
|
||||
// 优先从回复找图
|
||||
let reply
|
||||
if (e.isGroup) {
|
||||
reply = (await e.group.getChatHistory(e.source.seq, 1)).pop()?.message
|
||||
} else {
|
||||
reply = (await e.friend.getChatHistory(e.source.time, 1)).pop()?.message
|
||||
}
|
||||
if (reply) {
|
||||
for (let val of reply) {
|
||||
if (val.type === 'image') {
|
||||
console.log(val)
|
||||
img.push(val.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.img) {
|
||||
img.push(...e.img)
|
||||
}
|
||||
if (img.length > 0 && Config.extraUrl) {
|
||||
tools.push(new ImageCaptionTool())
|
||||
prompt += `\nthe url of the picture(s) above: ${img.join(', ')}`
|
||||
} else {
|
||||
tools.push(new SerpImageTool())
|
||||
tools.push(...[new SearchVideoTool(),
|
||||
new SendVideoTool(),
|
||||
new SearchMusicTool(),
|
||||
new SendMusicTool()])
|
||||
}
|
||||
// if (e.sender.role === 'admin' || e.sender.role === 'owner') {
|
||||
// tools.push(...[new JinyanTool(), new KickOutTool()])
|
||||
// }
|
||||
let funcMap = {}
|
||||
let fullFuncMap = {}
|
||||
tools.forEach(tool => {
|
||||
funcMap[tool.name] = {
|
||||
exec: tool.func,
|
||||
function: tool.function()
|
||||
}
|
||||
})
|
||||
fullTools.forEach(tool => {
|
||||
fullFuncMap[tool.name] = {
|
||||
exec: tool.func,
|
||||
function: tool.function()
|
||||
}
|
||||
})
|
||||
if (!option.completionParams) {
|
||||
option.completionParams = {}
|
||||
}
|
||||
option.completionParams.functions = Object.keys(funcMap).map(k => funcMap[k].function)
|
||||
let msg
|
||||
try {
|
||||
msg = await this.chatGPTApi.sendMessage(prompt, option)
|
||||
logger.info(msg)
|
||||
while (msg.functionCall) {
|
||||
let { name, arguments: args } = msg.functionCall
|
||||
let functionResult = await fullFuncMap[name].exec(Object.assign({ isAdmin, sender }, JSON.parse(args)))
|
||||
logger.mark(`function ${name} execution result: ${functionResult}`)
|
||||
option.parentMessageId = msg.id
|
||||
option.name = name
|
||||
// 不然普通用户可能会被openai限速
|
||||
await delay(300)
|
||||
msg = await this.chatGPTApi.sendMessage(functionResult, option, 'function')
|
||||
logger.info(msg)
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.message?.indexOf('context_length_exceeded') > 0) {
|
||||
logger.warn(err)
|
||||
await redis.del(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`)
|
||||
await redis.del(`CHATGPT:WRONG_EMOTION:${e.sender.user_id}`)
|
||||
await e.reply('字数超限啦,将为您自动结束本次对话。')
|
||||
return null
|
||||
} else {
|
||||
logger.error(err)
|
||||
throw new Error(err)
|
||||
}
|
||||
}
|
||||
return msg
|
||||
} else {
|
||||
let msg
|
||||
try {
|
||||
msg = await this.chatGPTApi.sendMessage(prompt, option)
|
||||
} catch (err) {
|
||||
if (err.message?.indexOf('context_length_exceeded') > 0) {
|
||||
logger.warn(err)
|
||||
await redis.del(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`)
|
||||
await redis.del(`CHATGPT:WRONG_EMOTION:${e.sender.user_id}`)
|
||||
await e.reply('字数超限啦,将为您自动结束本次对话。')
|
||||
return null
|
||||
} else {
|
||||
logger.error(err)
|
||||
throw new Error(err)
|
||||
}
|
||||
}
|
||||
return msg
|
||||
}
|
||||
return msg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,7 +203,8 @@ ${translateLangLabels}
|
|||
await e.reply('请在群里发送此命令')
|
||||
}
|
||||
}
|
||||
async wordcloud_latest(e) {
|
||||
|
||||
async wordcloud_latest (e) {
|
||||
if (e.isGroup) {
|
||||
let groupId = e.group_id
|
||||
let lock = await redis.get(`CHATGPT:WORDCLOUD:${groupId}`)
|
||||
|
|
@ -215,14 +216,14 @@ ${translateLangLabels}
|
|||
const regExp = /词云(\d{0,2})(|h)/
|
||||
const match = e.msg.trim().match(regExp)
|
||||
const duration = !match[1] ? 12 : parseInt(match[1]) // default 12h
|
||||
|
||||
|
||||
if(duration > 24) {
|
||||
await e.reply('最多只能统计24小时内的记录哦')
|
||||
return false
|
||||
}
|
||||
await e.reply('在统计啦,请稍等...')
|
||||
|
||||
await redis.set(`CHATGPT:WORDCLOUD:${groupId}`, '1', {EX: 600})
|
||||
|
||||
await redis.set(`CHATGPT:WORDCLOUD:${groupId}`, '1', { EX: 600 })
|
||||
try {
|
||||
await makeWordcloud(e, e.group_id, duration)
|
||||
} catch (err) {
|
||||
|
|
@ -471,28 +472,28 @@ ${translateLangLabels}
|
|||
await this.reply(replyMsg)
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
async screenshotUrl (e) {
|
||||
let url = e.msg.replace(/^#url(:|:)/, '')
|
||||
if (url.length === 0) { return false }
|
||||
try {
|
||||
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
||||
url = "http://" + url
|
||||
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
||||
url = 'http://' + url
|
||||
}
|
||||
let urlLink = new URL(url)
|
||||
await e.reply(
|
||||
await renderUrl(
|
||||
e, urlLink.href,
|
||||
{
|
||||
retType: 'base64',
|
||||
Viewport: {
|
||||
width: Config.chatViewWidth,
|
||||
height: parseInt(Config.chatViewWidth * 0.56)
|
||||
},
|
||||
deviceScaleFactor: Config.cloudDPR
|
||||
}
|
||||
e, urlLink.href,
|
||||
{
|
||||
retType: 'base64',
|
||||
Viewport: {
|
||||
width: Config.chatViewWidth,
|
||||
height: parseInt(Config.chatViewWidth * 0.56)
|
||||
},
|
||||
deviceScaleFactor: Config.cloudDPR
|
||||
}
|
||||
),
|
||||
e.isGroup && Config.quoteReply)
|
||||
e.isGroup && Config.quoteReply)
|
||||
} catch (err) {
|
||||
this.reply('无效url:' + url)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,6 +210,11 @@ let helpData = [
|
|||
icon: 'token',
|
||||
title: '#chatgpt设置后台刷新token',
|
||||
desc: '用于查看API余额。注意和配置的key保持同一账号。'
|
||||
},
|
||||
{
|
||||
icon: 'token',
|
||||
title: '#chatgpt(开启|关闭)智能模式',
|
||||
desc: 'API模式下打开或关闭智能模式。'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { Config } from '../utils/config.js'
|
||||
import { exec } from 'child_process'
|
||||
import {
|
||||
checkPnpm,
|
||||
formatDuration,
|
||||
getAzureRoleList,
|
||||
getPublicIP,
|
||||
|
|
@ -136,32 +134,32 @@ export class ChatgptManagement extends plugin {
|
|||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt(本群)?(群\\d+)?(开启|启动|激活|张嘴|开口|说话|上班)',
|
||||
reg: '^#chatgpt(本群)?(群\\d+)?(开启|启动|激活|张嘴|开口|说话|上班)$',
|
||||
fnc: 'openMouth',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt查看?(关闭|闭嘴|关机|休眠|下班|休眠)列表',
|
||||
reg: '^#chatgpt查看?(关闭|闭嘴|关机|休眠|下班|休眠)列表$',
|
||||
fnc: 'listShutUp',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt设置(API|key)(Key|key)',
|
||||
reg: '^#chatgpt设置(API|key)(Key|key)$',
|
||||
fnc: 'setAPIKey',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt设置(API|api)设定',
|
||||
reg: '^#chatgpt设置(API|api)设定$',
|
||||
fnc: 'setAPIPromptPrefix',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt设置星火token',
|
||||
reg: '^#chatgpt设置星火token$',
|
||||
fnc: 'setXinghuoToken',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt设置(Bing|必应|Sydney|悉尼|sydney|bing)设定',
|
||||
reg: '^#chatgpt设置(Bing|必应|Sydney|悉尼|sydney|bing)设定$',
|
||||
fnc: 'setBingPromptPrefix',
|
||||
permission: 'master'
|
||||
},
|
||||
|
|
@ -260,6 +258,11 @@ export class ChatgptManagement extends plugin {
|
|||
reg: '^#chatgpt导入配置',
|
||||
fnc: 'importConfig',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt(开启|关闭)智能模式$',
|
||||
fnc: 'switchSmartMode',
|
||||
permission: 'master'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
|
@ -313,9 +316,7 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务,
|
|||
roleList = getVoicevoxRoleList()
|
||||
break
|
||||
case 'azure':
|
||||
if (matchCommand[2] === 'azure') {
|
||||
roleList = getAzureRoleList()
|
||||
}
|
||||
roleList = getAzureRoleList()
|
||||
break
|
||||
default:
|
||||
break
|
||||
|
|
@ -1006,6 +1007,7 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务,
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async versionChatGPTPlugin (e) {
|
||||
await renderUrl(e, `http://127.0.0.1:${Config.serverPort || 3321}/version`, { Viewport: { width: 800, height: 600 } })
|
||||
}
|
||||
|
|
@ -1391,7 +1393,7 @@ Poe 模式会调用 Poe 中的 Claude-instant 进行对话。需要提供 Cookie
|
|||
})
|
||||
console.log(configJson)
|
||||
const buf = Buffer.from(configJson)
|
||||
e.friend.sendFile(buf, `ChatGPT-Plugin Config ${new Date}.json`)
|
||||
e.friend.sendFile(buf, `ChatGPT-Plugin Config ${new Date()}.json`)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -1419,8 +1421,8 @@ Poe 模式会调用 Poe 中的 Claude-instant 进行对话。需要提供 Cookie
|
|||
if (Config[keyPath] != value) {
|
||||
changeConfig.push({
|
||||
item: keyPath,
|
||||
value: typeof(value) === 'object' ? JSON.stringify(value): value,
|
||||
old: typeof(Config[keyPath]) === 'object' ? JSON.stringify(Config[keyPath]): Config[keyPath],
|
||||
value: typeof (value) === 'object' ? JSON.stringify(value) : value,
|
||||
old: typeof (Config[keyPath]) === 'object' ? JSON.stringify(Config[keyPath]) : Config[keyPath],
|
||||
type: 'config'
|
||||
})
|
||||
Config[keyPath] = value
|
||||
|
|
@ -1454,18 +1456,35 @@ Poe 模式会调用 Poe 中的 Claude-instant 进行对话。需要提供 Cookie
|
|||
})
|
||||
await redis.set('CHATGPT:USE', redisConfig.useMode)
|
||||
}
|
||||
await this.reply(await makeForwardMsg(this.e, changeConfig.map(msg => `修改项:${msg.item}\n旧数据\n\n${msg.url}\n\n新数据\n ${msg.url}`)))
|
||||
await this.reply(await makeForwardMsg(this.e, changeConfig.map(msg => `修改项:${msg.item}\n旧数据\n\n${msg.old}\n\n新数据\n ${msg.value}`)))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
await e.reply('配置文件错误')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await this.reply(`未找到配置文件`, false)
|
||||
await this.reply('未找到配置文件', false)
|
||||
return false
|
||||
}
|
||||
|
||||
this.finish('doImportConfig')
|
||||
}
|
||||
|
||||
async switchSmartMode (e) {
|
||||
if (e.msg.includes('开启')) {
|
||||
if (Config.smartMode) {
|
||||
await e.reply('已经开启了')
|
||||
return
|
||||
}
|
||||
Config.smartMode = true
|
||||
await e.reply('好的,已经打开智能模式,注意API额度哦。配合开启读取群聊上下文效果更佳!')
|
||||
} else {
|
||||
if (!Config.smartMode) {
|
||||
await e.reply('已经是关闭得了')
|
||||
return
|
||||
}
|
||||
Config.smartMode = false
|
||||
await e.reply('好的,已经关闭智能模式')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue