Skip to content

Commit

Permalink
feat: add 简洁模式
Browse files Browse the repository at this point in the history
  • Loading branch information
misaka20002 committed Oct 9, 2024
1 parent accd8ab commit 6b788b0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
26 changes: 18 additions & 8 deletions apps/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,22 @@ export class FLUXDEV extends plugin {
let userPrompt = param.input

let finalPrompt = userPrompt
let onleReplyOnce = 0;
if (this.config.generatePrompt) {
this.reply('请稍等哦,正在生成提示词...')
if (!onleReplyOnce && !this.config.simpleMode) {
this.reply(`@${e.sender.card || e.sender.nickname} ${e.user_id}正在为您生成提示词并绘图...`)
onleReplyOnce++
}
finalPrompt = await this.generatePrompt(userPrompt)
if (!finalPrompt) {
await this.reply('生成提示词失败,请稍后再试。')
return
}
}

this.reply('正在生成图片...')
if (!onleReplyOnce && !this.config.simpleMode) {
this.reply(`@${e.sender.card || e.sender.nickname} ${e.user_id}正在为您生成图片...`)
onleReplyOnce++
}

logger.mark("[sf插件]开始图片生成API调用")
try {
Expand All @@ -148,7 +154,7 @@ export class FLUXDEV extends plugin {
if (data?.images?.[0]?.url) {
const imageUrl = data.images[0].url

const strs = `${canImg2Img ? "图生图" : "文生图"}完成
const strs = `@${e.sender.card || e.sender.nickname} ${e.user_id}您的${canImg2Img ? "图生图" : "文生图"}已完成
原始提示词:${userPrompt}
最终提示词:${finalPrompt}
负面提示词:${param.parameters.negative_prompt ? param.parameters.negative_prompt : "sf默认"}
Expand All @@ -159,10 +165,14 @@ export class FLUXDEV extends plugin {
生成时间:${data.timings.inference.toFixed(2)}
种子:${data.seed}`

const msgx = await common.makeForwardMsg(e, strs, `${canImg2Img ? "图生图" : "文生图"}${userPrompt}`)
this.reply(msgx)

this.reply(segment.image(imageUrl))
if (this.config.simpleMode) {
const msgx = await common.makeForwardMsg(e, [await segment.image(imageUrl), strs], `${e.sender.card || e.sender.nickname}${canImg2Img ? "图生图" : "文生图"}`)
this.reply(msgx)
} else {
const msgx = await common.makeForwardMsg(e, strs, `${e.sender.card || e.sender.nickname}${canImg2Img ? "图生图" : "文生图"}`)
this.reply(msgx)
this.reply(segment.image(imageUrl))
}
} else {
logger.error("[sf插件]返回错误:\n", data)
this.reply(`生成图片失败:${data.message || '未知错误'}`)
Expand Down
3 changes: 2 additions & 1 deletion config/config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ translateModel: "Vendor-A/Qwen/Qwen2-72B-Instruct"
generatePrompt: true
num_inference_steps: 20
imageModel: "black-forest-labs/FLUX.1-schnell"
free_mode: false
free_mode: false
simpleMode: false
6 changes: 6 additions & 0 deletions guoba.support.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ export function supportGuoba() {
bottomHelpMessage: "开启后可以绘制更大的图片和更多的步数;注意额度消耗",
component: "Switch",
},
{
field: "simpleMode",
label: "简洁模式",
bottomHelpMessage: "开启后合并输出图片与prompt,且不提示进入绘画队列",
component: "Switch",
},
{
field: "num_inference_steps",
label: "推理步数",
Expand Down

0 comments on commit 6b788b0

Please sign in to comment.