mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
优化和错误修复 (#527)
* 修复后台API反代地址未能正确显示的问题 * 更新渲染页面配置 * 添加个人聊天模式配置 * 将用户数据获取改到common中 * 修复错误的渲染页面参数 * 修复bug * 添加Live2D * 修复渲染页面错误 * 修复渲染传入值 * 更新渲染 * 修复图表渲染bug * 调整live2d模型大小 * 修复live2d无法关闭问题 * 修复错误的传值 * 修复ai命名 * 更新渲染 * 添加用户独立设定 * 更新渲染配置适配个人设置 * 修复合并导致的渲染文件异常删除 * 修复用户数据缺失问题 * 修复旧版本数据缺失问题 * 修复bing参数不存在问题,兼容miao的截图 * 修复受限token重试时不被排除的问题 * 修复个人模式下结束对话的模式错误 * 更新渲染页面,将预览版转为正式版 * 修复传统渲染无法调用截图功能的问题 * 文字模式也进行一次缓存 * 更新README * Update README.md * 更新渲染 * 更新渲染页面 * 添加版本信息 * 遗漏参数 * 丢失引用 * 补充路由 * 添加云转码功能 * 判断node-silk是否正常合成 * 云转码提示 * 修复图片渲染出错 * 云转码支持发送Buffer * 添加云转码模式支持 * 更新描述 * 更新后台渲染页面 * 更新配置 * 更新渲染页面 * 添加云渲染 * 修复错误的接口调用 * 修复遗漏的数据转换 * 修复获取的图片数据异常问题 * 更新后台配置 * 更新渲染页面 * 修复云渲染访问地址错误 * 更新渲染页面 * 修复遗漏的模型文件 * 修复live2d问题 * 更新live2d以及相关配置 * 修复遗漏的数据参数 * 修复新live2d情况下云渲染错误的问题 * 适配云渲染1.1.2等待参数 * 添加云服务api检查 * 更新渲染页面 * 添加live2d加载检测 * 修复错误的属性判断 * 添加云渲染DPR * 更新sydney支持内容生成 * 修改文件模式语音转码接收模式 * 添加云转码时recordUrl检查 * 更新后台配置项 * 修复错误的文本描述 * 更新后台页面 * 添加全局对话模式设置,更新后台面板 * 添加第三方渲染服务适配 * 修复第三方服务器live2d加载导致的渲染失败问题 * 修复后台地址无法实时保存的问题 * 添加live2d模型透明度设置 * 合并更新 * 更新渲染页面 * 更新渲染页面 * 使dpr对本地渲染也生效 * 更新渲染页面 * 添加网页截图功能 * 添加后台配置项 * 添加配置导出和导入功能 * 运行通过参数传递用户token * 登录时将token作为参数返回 * 修复错误 * 添加密码修改和用户删除接口 * 修正密码比对 * 修复user错误 * 优化数据保存时的返回值 * 添加系统额外服务检查api * 添加AccessToken配置 * 修复错误的导入提示 * 添加ws连接 * 添加ws用户信息获取 * 修复错误的循环 * 修正ws参数 * 添加群消息获取权限 * 添加用户多端登录支持 * 修复错误的路径引用 * 修复错误的路径引用 * 修复错误 * 修复页面数据获取失败问题 * 修复异常的中断 * 添加配置视图 * 更新配置面板 * 添加用户版本信息 * 更新配置视图 * 修复错误的视图绑定 * 修改视图文件位置,添加mediaLink相关代码 * 修复错误的视图配置绑定 * 更新依赖,添加qq消息组件初始化信息获取 * 修复异常的群名称无法获取问题 * 修改注释 * 撤销对management的错误合并 * 添加Sydney图片识别功能 * 更新配置文件和后台页面 * 修改view配置 * 修复node版本过低导致的FormData无法调用,尝试添加反代 * 国外图片识别不使用反代 * fix: 修复云转码导致的语音重复发送问题 * fix: 修复qq消息可越权获取的问题 * feat: 添加代理post操作 * fix: 修复一些字符串格式的数字导致的配置加载错误 * fix: 修复错误的云服务api网址格式 * fix: 修复错误的云转码接口调用格式 * fix: 修复错误的精度 --------- Co-authored-by: ikechan8370 <geyinchibuaa@gmail.com>
This commit is contained in:
parent
a703378cb1
commit
709a1cebf0
9 changed files with 258 additions and 202 deletions
|
|
@ -28,7 +28,7 @@ if (!globalThis.fetch) {
|
|||
// }
|
||||
// return WebSocket
|
||||
// }
|
||||
async function getKeyv () {
|
||||
async function getKeyv() {
|
||||
let Keyv
|
||||
try {
|
||||
Keyv = (await import('keyv')).default
|
||||
|
|
@ -45,7 +45,7 @@ async function getKeyv () {
|
|||
const genRanHex = (size) => [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join('')
|
||||
|
||||
export default class SydneyAIClient {
|
||||
constructor (opts) {
|
||||
constructor(opts) {
|
||||
this.opts = {
|
||||
...opts,
|
||||
host: opts.host || Config.sydneyReverseProxy || 'https://edgeservices.bing.com/edgesvc'
|
||||
|
|
@ -56,7 +56,7 @@ export default class SydneyAIClient {
|
|||
this.debug = opts.debug
|
||||
}
|
||||
|
||||
async initCache () {
|
||||
async initCache() {
|
||||
if (!this.conversationsCache) {
|
||||
const cacheOptions = this.opts.cache || {}
|
||||
cacheOptions.namespace = cacheOptions.namespace || 'bing'
|
||||
|
|
@ -65,7 +65,7 @@ export default class SydneyAIClient {
|
|||
}
|
||||
}
|
||||
|
||||
async createNewConversation () {
|
||||
async createNewConversation() {
|
||||
await this.initCache()
|
||||
const fetchOptions = {
|
||||
headers: {
|
||||
|
|
@ -130,7 +130,7 @@ export default class SydneyAIClient {
|
|||
}
|
||||
}
|
||||
|
||||
async createWebSocketConnection () {
|
||||
async createWebSocketConnection() {
|
||||
await this.initCache()
|
||||
// let WebSocket = await getWebSocket()
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
@ -194,13 +194,13 @@ export default class SydneyAIClient {
|
|||
})
|
||||
}
|
||||
|
||||
async cleanupWebSocketConnection (ws) {
|
||||
async cleanupWebSocketConnection(ws) {
|
||||
clearInterval(ws.bingPingInterval)
|
||||
ws.close()
|
||||
ws.removeAllListeners()
|
||||
}
|
||||
|
||||
async sendMessage (
|
||||
async sendMessage(
|
||||
message,
|
||||
opts = {}
|
||||
) {
|
||||
|
|
@ -367,7 +367,6 @@ export default class SydneyAIClient {
|
|||
}
|
||||
const currentDate = moment().format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
const imageDate = await this.kblobImage(opts.imageUrl)
|
||||
// console.log(imageDate)
|
||||
const obj = {
|
||||
arguments: [
|
||||
{
|
||||
|
|
@ -575,9 +574,9 @@ export default class SydneyAIClient {
|
|||
const message = messages.length
|
||||
? messages[messages.length - 1]
|
||||
: {
|
||||
adaptiveCards: adaptiveCardsSoFar,
|
||||
text: replySoFar.join('')
|
||||
}
|
||||
adaptiveCards: adaptiveCardsSoFar,
|
||||
text: replySoFar.join('')
|
||||
}
|
||||
if (messages[0].contentOrigin === 'Apology') {
|
||||
console.log('Apology found')
|
||||
if (!replySoFar[0]) {
|
||||
|
|
@ -642,9 +641,9 @@ export default class SydneyAIClient {
|
|||
const message = messages.length
|
||||
? messages[messages.length - 1]
|
||||
: {
|
||||
adaptiveCards: adaptiveCardsSoFar,
|
||||
text: replySoFar.join('')
|
||||
}
|
||||
adaptiveCards: adaptiveCardsSoFar,
|
||||
text: replySoFar.join('')
|
||||
}
|
||||
// 获取到图片内容
|
||||
if (message.contentType === 'IMAGE') {
|
||||
message.imageTag = messages.filter(m => m.contentType === 'IMAGE').map(m => m.text).join('')
|
||||
|
|
@ -808,7 +807,6 @@ export default class SydneyAIClient {
|
|||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through messages, building an array based on the parentMessageId.
|
||||
* Each message has an id and a parentMessageId. The parentMessageId is the id of the message that this message is a reply to.
|
||||
|
|
@ -816,7 +814,7 @@ export default class SydneyAIClient {
|
|||
* @param parentMessageId
|
||||
* @returns {*[]} An array containing the messages in the order they should be displayed, starting with the root message.
|
||||
*/
|
||||
static getMessagesForConversation (messages, parentMessageId) {
|
||||
static getMessagesForConversation(messages, parentMessageId) {
|
||||
const orderedMessages = []
|
||||
let currentMessageId = parentMessageId
|
||||
while (currentMessageId) {
|
||||
|
|
@ -832,7 +830,7 @@ export default class SydneyAIClient {
|
|||
}
|
||||
}
|
||||
|
||||
async function generateRandomIP () {
|
||||
async function generateRandomIP() {
|
||||
let ip = await redis.get('CHATGPT:BING_IP')
|
||||
if (ip) {
|
||||
return ip
|
||||
|
|
|
|||
|
|
@ -346,7 +346,8 @@ export async function renderUrl (e, url, renderCfg = {}) {
|
|||
// 云渲染
|
||||
if (Config.cloudRender) {
|
||||
url = url.replace(`127.0.0.1:${Config.serverPort || 3321}`, Config.serverHost || `${await getPublicIP()}:${Config.serverPort || 3321}`)
|
||||
const resultres = await fetch(`${Config.cloudTranscode}/screenshot`, {
|
||||
const cloudUrl = new URL(Config.cloudTranscode)
|
||||
const resultres = await fetch(`${cloudUrl.href}screenshot`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
|
@ -844,9 +845,7 @@ export async function generateAudio (e, pendingText, speakingEmotion, emotionDeg
|
|||
try {
|
||||
try {
|
||||
sendable = await uploadRecord(wav, Config.ttsMode)
|
||||
if (sendable) {
|
||||
await e.reply(sendable)
|
||||
} else {
|
||||
if (!sendable) {
|
||||
// 如果合成失败,尝试使用ffmpeg合成
|
||||
sendable = segment.record(wav)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ function randomNum (minNum, maxNum) {
|
|||
* @param lengthScale
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
export async function generateVitsAudio (text, speaker = '随机', language = '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)', noiseScale = Config.noiseScale, noiseScaleW = Config.noiseScaleW, lengthScale = Config.lengthScale) {
|
||||
export async function generateVitsAudio (text, speaker = '随机', language = '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)', noiseScale = parseFloat(Config.noiseScale), noiseScaleW = parseFloat(Config.noiseScaleW), lengthScale = parseFloat(Config.lengthScale)) {
|
||||
if (!speaker || speaker === '随机') {
|
||||
logger.info('随机角色!这次哪个角色这么幸运会被选到呢……')
|
||||
speaker = speakers[randomNum(0, speakers.length)]
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ async function uploadRecord (recordUrl, ttsMode = 'vits-uma-genshin-honkai') {
|
|||
buffer = Buffer.from(arrayBuffer)
|
||||
formData.append('file', new File([buffer], 'audio.wav'))
|
||||
}
|
||||
const resultres = await fetch(`${Config.cloudTranscode}/audio`, {
|
||||
const cloudUrl = new URL(Config.cloudTranscode)
|
||||
const resultres = await fetch(`${cloudUrl}audio`, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
|
|
@ -99,7 +100,8 @@ async function uploadRecord (recordUrl, ttsMode = 'vits-uma-genshin-honkai') {
|
|||
throw e
|
||||
}
|
||||
} else {
|
||||
const resultres = await fetch(`${Config.cloudTranscode}/audio`, {
|
||||
const cloudUrl = new URL(Config.cloudTranscode)
|
||||
const resultres = await fetch(`${cloudUrl}audio`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue