forked from pinks/eris
1
0
Fork 0

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

Reviewed-on: pinks/eris#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; 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(