mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 22:07:10 +00:00
使用ap替换第三方绘图
This commit is contained in:
parent
0666de1aaa
commit
20ea8cfabf
3 changed files with 9 additions and 49 deletions
30
apps/chat.js
30
apps/chat.js
|
|
@ -1665,32 +1665,12 @@ export class chatgpt extends plugin {
|
||||||
if (Config.debug) {
|
if (Config.debug) {
|
||||||
logger.mark(`开始生成内容:${response.details.imageTag}`)
|
logger.mark(`开始生成内容:${response.details.imageTag}`)
|
||||||
}
|
}
|
||||||
if (Config.bingDrawApi) {
|
if (Config.bingAPDraw) {
|
||||||
// 调用第三方API进行绘图
|
// 调用第三方API进行绘图
|
||||||
const drawOption = {
|
let apDraw = new APTool()
|
||||||
method: 'POST',
|
apDraw.func({
|
||||||
headers: {'content-type': 'application/json'},
|
prompt: response.details.imageTag
|
||||||
body: JSON.stringify({
|
}, e)
|
||||||
prompt: response.details.imageTag,
|
|
||||||
width: Config.bingDrawWidth || 512,
|
|
||||||
height: Config.bingDrawHeight || 512,
|
|
||||||
sampler_index: Config.bingDrawSampler || 'DPM++ 2M SDE'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const drawData = await fetch(Config.bingDrawApi, drawOption)
|
|
||||||
if (drawData.ok) {
|
|
||||||
let draw = await drawData.json()
|
|
||||||
if (draw.images?.length > 0) {
|
|
||||||
for(let image of draw.images) {
|
|
||||||
this.reply(segment.image(`base64://${image}`), true)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
await e.reply('绘图失败:未产生图片')
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
await e.reply('绘图失败:第三方绘图服务器错误')
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
let client = new BingDrawClient({
|
let client = new BingDrawClient({
|
||||||
baseUrl: Config.sydneyReverseProxy,
|
baseUrl: Config.sydneyReverseProxy,
|
||||||
|
|
|
||||||
|
|
@ -638,27 +638,10 @@
|
||||||
"data": "bingCaptchaOneShotUrl"
|
"data": "bingCaptchaOneShotUrl"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "url",
|
"type": "check",
|
||||||
"label": "第三方绘图",
|
"label": "第三方绘图",
|
||||||
"placeholder": "Stable Diffusion API地址",
|
"placeholder": "使用AP插件代替Bing进行绘图",
|
||||||
"data": "bingDrawApi"
|
"data": "bingAPDraw"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"label": "第三方绘图采样方法",
|
|
||||||
"data": "bingDrawSampler"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "number",
|
|
||||||
"label": "第三方绘图宽度",
|
|
||||||
"placeholder": "图片宽度",
|
|
||||||
"data": "bingDrawWidth"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "number",
|
|
||||||
"label": "第三方绘图高度",
|
|
||||||
"placeholder": "图片高度",
|
|
||||||
"data": "bingDrawHeight"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -96,10 +96,7 @@ const defaultConfig = {
|
||||||
maxNumUserMessagesInConversation: 20,
|
maxNumUserMessagesInConversation: 20,
|
||||||
sydneyApologyIgnored: true,
|
sydneyApologyIgnored: true,
|
||||||
enforceMaster: false,
|
enforceMaster: false,
|
||||||
bingDrawApi: '',
|
bingAPDraw: false,
|
||||||
bingDrawSampler: '',
|
|
||||||
bingDrawWidth: 512,
|
|
||||||
bingDrawHeight: 512,
|
|
||||||
serverPort: 3321,
|
serverPort: 3321,
|
||||||
serverHost: '',
|
serverHost: '',
|
||||||
viewHost: '',
|
viewHost: '',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue