为图片添加外部页面保存 (#167)

* 修复引用转发,默认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

---------

Co-authored-by: ikechan8370 <geyinchibuaa@gmail.com>
This commit is contained in:
HalcyonAlcedo 2023-02-19 00:17:37 +08:00 committed by GitHub
parent de4a6c8f41
commit a4f12eaf09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 132 additions and 7 deletions

View file

@ -442,7 +442,28 @@ export class chatgpt extends plugin {
let converted = response // converter.makeHtml(response)
/** 最后回复消息 */
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: converted, prompt, senderName: e.sender.nickname })
if (Config.showQRCode) {
let cacheres = await fetch('http://content.alcedogroup.com/cache', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: {
content: converted,
prompt,
senderName: e.sender.nickname
// quote: quotemessage
},
bing: use === 'bing'
})
}
)
let cache = await cacheres.json()
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: converted, prompt, senderName: e.sender.nickname, cache: cache.file })
} else {
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: converted, prompt, senderName: e.sender.nickname })
}
} else {
let quotemessage = []
if (chatMessage?.quote) {
@ -454,7 +475,28 @@ export class chatgpt extends plugin {
}
if (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold) {
// 文字过多时自动切换到图片模式输出
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: response, prompt, quote: quotemessage, senderName: e.sender.nickname })
if (Config.showQRCode) {
let cacheres = await fetch('http://content.alcedogroup.com/cache', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: {
content: response,
prompt,
senderName: e.sender.nickname,
quote: quotemessage
},
bing: use === 'bing'
})
}
)
let cache = await cacheres.json()
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: converted, prompt, senderName: e.sender.nickname, cache: cache.file })
} else {
await e.runtime.render('chatgpt-plugin', use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', { content: converted, prompt, senderName: e.sender.nickname })
}
} else {
await this.reply(`${response}`, e.isGroup)
if (quotemessage.length > 0) {