fix(nodes): fix missing generation modes

Lax typing on the metadata util functions allowed a typing issue to slip through. Fixed the lax typing, updated core metadata node.
This commit is contained in:
psychedelicious 2023-10-20 16:22:56 +11:00
parent 7b066681f0
commit 8615d53e65
4 changed files with 126 additions and 40 deletions

View File

@ -107,11 +107,16 @@ class MergeMetadataInvocation(BaseInvocation):
return MetadataOutput(metadata=MetadataField.model_validate(data)) return MetadataOutput(metadata=MetadataField.model_validate(data))
GENERATION_MODES = Literal[
"txt2img", "img2img", "inpaint", "outpaint", "sdxl_txt2img", "sdxl_img2img", "sdxl_inpaint", "sdxl_outpaint"
]
@invocation("core_metadata", title="Core Metadata", tags=["metadata"], category="metadata", version="1.0.0") @invocation("core_metadata", title="Core Metadata", tags=["metadata"], category="metadata", version="1.0.0")
class CoreMetadataInvocation(BaseInvocation): class CoreMetadataInvocation(BaseInvocation):
"""Collects core generation metadata into a MetadataField""" """Collects core generation metadata into a MetadataField"""
generation_mode: Literal["txt2img", "img2img", "inpaint", "outpaint"] = InputField( generation_mode: Optional[GENERATION_MODES] = InputField(
default=None, default=None,
description="The generation mode that output this image", description="The generation mode that output this image",
) )

View File

@ -7,7 +7,7 @@ import {
SaveImageInvocation, SaveImageInvocation,
} from 'services/api/types'; } from 'services/api/types';
import { REALESRGAN as ESRGAN, SAVE_IMAGE } from './constants'; import { REALESRGAN as ESRGAN, SAVE_IMAGE } from './constants';
import { addCoreMetadataNode } from './metadata'; import { addCoreMetadataNode, upsertMetadata } from './metadata';
type Arg = { type Arg = {
image_name: string; image_name: string;
@ -56,7 +56,8 @@ export const buildAdHocUpscaleGraph = ({
], ],
}; };
addCoreMetadataNode(graph, { addCoreMetadataNode(graph, {});
upsertMetadata(graph, {
esrgan_model: esrganModelName, esrgan_model: esrganModelName,
}); });

View File

@ -5,7 +5,7 @@ import { METADATA, SAVE_IMAGE } from './constants';
export const addCoreMetadataNode = ( export const addCoreMetadataNode = (
graph: NonNullableGraph, graph: NonNullableGraph,
metadata: Partial<CoreMetadataInvocation> | JsonObject metadata: Partial<CoreMetadataInvocation>
): void => { ): void => {
graph.nodes[METADATA] = { graph.nodes[METADATA] = {
id: METADATA, id: METADATA,

File diff suppressed because one or more lines are too long