feat: parse seed on new txt2img request (#20)

Reviewed-on: #20
Co-authored-by: nameless <nameless@noreply@foxo.me>
Co-committed-by: nameless <nameless@noreply@foxo.me>
This commit is contained in:
nameless 2023-10-14 10:57:46 +00:00 committed by pinks
parent d9f8966ad8
commit 07fc0c71f2
2 changed files with 10 additions and 3 deletions

View File

@ -25,7 +25,7 @@ interface PngInfoExtra extends PngInfo {
upscale?: number;
}
export function parsePngInfo(pngInfo: string, baseParams?: Partial<PngInfo>): Partial<PngInfo> {
export function parsePngInfo(pngInfo: string, baseParams?: Partial<PngInfo>, shouldParseSeed?: boolean): Partial<PngInfo> {
const tags = pngInfo.split(/[,;]+|\.+\s|\n/u);
let part: "prompt" | "negative_prompt" | "params" = "prompt";
const params: Partial<PngInfoExtra> = {};
@ -99,7 +99,14 @@ export function parsePngInfo(pngInfo: string, baseParams?: Partial<PngInfo>): Pa
params.denoising_strength = denoisingStrength;
break;
}
case "seed":
case "seed": {
part = "params";
if (shouldParseSeed) {
const seed = Number(value.trim());
params.seed = seed;
break;
}
}
case "model":
case "modelhash":
case "modelname":

View File

@ -64,7 +64,7 @@ async function txt2img(ctx: ErisContext, match: string, includeRepliedTo: boolea
params = parsePngInfo(repliedToText, params);
}
params = parsePngInfo(match, params);
params = parsePngInfo(match, params, true);
if (!params.prompt) {
await ctx.reply(