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:
parent
d9f8966ad8
commit
07fc0c71f2
|
@ -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":
|
||||||
|
|
|
@ -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(
|
||||||
|
|
Loading…
Reference in New Issue