feat: parse seed on new txt2img request

This commit is contained in:
nameless 2023-10-13 22:02:15 +00:00
parent d9f8966ad8
commit 5e46314cc5
2 changed files with 10 additions and 3 deletions

View File

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

View File

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