mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
使用base64代替escapeHtml就传入数据 (#178)
* 修复引用转发,默认bing模式并发 * 开启stream增加稳定性 * fix: remove queue element only in non-bing mode * 使用chatgpt-api自带的超时逻辑,文字过多时启动切换到图片输出防止被吞 * Update chat.js * 添加Bing专用的图片输出样式 * 添加chatgpt的新图片模式,临时处理切换api导致的对话异常 * 修改bing样式表 * 为图片添加外部页面缓存 * 为图片模式添加MathJax * feat: add switch for qrcode * 防止script攻击 * 修复网页模板错误 * 修复bing页面引用错误 * 缓存服务器异常时处理 * 添加默认配置加载 * 修复配置文件路径错误 * 删除重复的模板文件,修复二维码地址错误 * 修正图片渲染错误 * 修复引用渲染错误 * 二维码网址统一改为使用本地配置 * 添加关闭思考提示的配置项 * 修复在Windows上无法载入配置文件的问题 * 修复关闭qr的情况下渲染错误 * 改为使用base64传递返回数据 --------- Co-authored-by: ikechan8370 <geyinchibuaa@gmail.com>
This commit is contained in:
parent
59d5e904b5
commit
ae161ed4ce
4 changed files with 22 additions and 10 deletions
10
apps/chat.js
10
apps/chat.js
|
|
@ -450,6 +450,7 @@ export class chatgpt extends plugin {
|
|||
// todo部分数学公式可能还有问题
|
||||
|
||||
/** 最后回复消息 */
|
||||
response = new Buffer.from(response).toString("base64")
|
||||
if (Config.showQRCode) {
|
||||
let cacheres = await fetch(`${Config.cacheUrl}/cache`, {
|
||||
method: 'POST',
|
||||
|
|
@ -471,9 +472,9 @@ export class chatgpt extends plugin {
|
|||
if (cacheres.ok) {
|
||||
cache = Object.assign({}, cache, await cacheres.json())
|
||||
}
|
||||
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: escapeHtml(response), prompt: escapeHtml(prompt), senderName: e.sender.nickname, cache: cache })
|
||||
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: response, prompt: escapeHtml(prompt), senderName: e.sender.nickname, cache: cache })
|
||||
} else {
|
||||
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: escapeHtml(response), prompt: escapeHtml(prompt), senderName: e.sender.nickname, cache: {file:'',cacheUrl:Config.cacheUrl} })
|
||||
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: response, prompt: escapeHtml(prompt), senderName: e.sender.nickname, cache: {file:'',cacheUrl:Config.cacheUrl} })
|
||||
}
|
||||
} else {
|
||||
let quotemessage = []
|
||||
|
|
@ -485,6 +486,7 @@ export class chatgpt extends plugin {
|
|||
})
|
||||
}
|
||||
if (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold) {
|
||||
response = new Buffer.from(response).toString("base64")
|
||||
// 文字过多时自动切换到图片模式输出
|
||||
if (Config.showQRCode) {
|
||||
let cacheres = await fetch(`${Config.cacheUrl}/cache`, {
|
||||
|
|
@ -507,9 +509,9 @@ export class chatgpt extends plugin {
|
|||
if (cacheres.ok) {
|
||||
cache = Object.assign({}, cache, await cacheres.json())
|
||||
}
|
||||
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: escapeHtml(response), prompt: escapeHtml(prompt), senderName: e.sender.nickname, quote: quotemessage.length > 0 , quotes: quotemessage, cache: cache })
|
||||
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: response, prompt: escapeHtml(prompt), senderName: e.sender.nickname, quote: quotemessage.length > 0 , quotes: quotemessage, cache: cache })
|
||||
} else {
|
||||
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: escapeHtml(response), prompt: escapeHtml(prompt), senderName: e.sender.nickname, quote: quotemessage.length > 0 , quotes: quotemessage, cache: {file:'',cacheUrl:Config.cacheUrl} })
|
||||
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: response, prompt: escapeHtml(prompt), senderName: e.sender.nickname, quote: quotemessage.length > 0 , quotes: quotemessage, cache: {file:'',cacheUrl:Config.cacheUrl} })
|
||||
}
|
||||
} else {
|
||||
await this.reply(`${response}`, e.isGroup)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue