mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +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) {
|
||||
logger.mark(`开始生成内容:${response.details.imageTag}`)
|
||||
}
|
||||
if (Config.bingDrawApi) {
|
||||
if (Config.bingAPDraw) {
|
||||
// 调用第三方API进行绘图
|
||||
const drawOption = {
|
||||
method: 'POST',
|
||||
headers: {'content-type': 'application/json'},
|
||||
body: JSON.stringify({
|
||||
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('绘图失败:第三方绘图服务器错误')
|
||||
}
|
||||
|
||||
let apDraw = new APTool()
|
||||
apDraw.func({
|
||||
prompt: response.details.imageTag
|
||||
}, e)
|
||||
} else {
|
||||
let client = new BingDrawClient({
|
||||
baseUrl: Config.sydneyReverseProxy,
|
||||
|
|
|
|||
|
|
@ -638,27 +638,10 @@
|
|||
"data": "bingCaptchaOneShotUrl"
|
||||
},
|
||||
{
|
||||
"type": "url",
|
||||
"type": "check",
|
||||
"label": "第三方绘图",
|
||||
"placeholder": "Stable Diffusion API地址",
|
||||
"data": "bingDrawApi"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"label": "第三方绘图采样方法",
|
||||
"data": "bingDrawSampler"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"label": "第三方绘图宽度",
|
||||
"placeholder": "图片宽度",
|
||||
"data": "bingDrawWidth"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"label": "第三方绘图高度",
|
||||
"placeholder": "图片高度",
|
||||
"data": "bingDrawHeight"
|
||||
"placeholder": "使用AP插件代替Bing进行绘图",
|
||||
"data": "bingAPDraw"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -96,10 +96,7 @@ const defaultConfig = {
|
|||
maxNumUserMessagesInConversation: 20,
|
||||
sydneyApologyIgnored: true,
|
||||
enforceMaster: false,
|
||||
bingDrawApi: '',
|
||||
bingDrawSampler: '',
|
||||
bingDrawWidth: 512,
|
||||
bingDrawHeight: 512,
|
||||
bingAPDraw: false,
|
||||
serverPort: 3321,
|
||||
serverHost: '',
|
||||
viewHost: '',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue