修复bing绘图第三方调用错误

This commit is contained in:
zyc404 2023-10-12 16:50:06 +08:00
parent fed2fd8dd4
commit 7c45b050ca

View file

@ -1669,6 +1669,7 @@ export class chatgpt extends plugin {
// 调用第三方API进行绘图 // 调用第三方API进行绘图
const drawOption = { const drawOption = {
method: 'POST', method: 'POST',
headers: {'content-type': 'application/json'},
body: JSON.stringify({ body: JSON.stringify({
prompt: response.details.imageTag, prompt: response.details.imageTag,
width: 512, width: 512,
@ -1677,11 +1678,13 @@ export class chatgpt extends plugin {
} }
const drawData = await fetch(Config.bingDrawApi, drawOption) const drawData = await fetch(Config.bingDrawApi, drawOption)
if (drawData.ok) { if (drawData.ok) {
let draw = await cacheres.json() let draw = await drawData.json()
if (draw.images) { if (draw.images?.length > 0) {
for(let image of draw.images) { for(let image of draw.images) {
this.reply(segment.image(`base64://${image}`), true) this.reply(segment.image(`base64://${image}`), true)
} }
} else {
await e.reply('绘图失败:未产生图片')
} }
} else { } else {
await e.reply('绘图失败:第三方绘图服务器错误') await e.reply('绘图失败:第三方绘图服务器错误')