fix(nodes): fix missing generation modes (#4960)

## What type of PR is this? (check all applicable)

- [ ] Refactor
- [ ] Feature
- [x] Bug Fix
- [ ] Optimization
- [ ] Documentation Update
- [ ] Community Node Submission


## Have you discussed this change with the InvokeAI team?
- [x] Yes
- [ ] No, because:

## Description

[fix(nodes): fix missing generation
modes](8615d53e65)

Lax typing on the metadata util functions allowed a typing issue to slip
through. Fixed the lax typing, updated core metadata node.

## Related Tickets & Documents

<!--
For pull requests that relate or close an issue, please include them
below. 

For example having the text: "closes #1234" would connect the current
pull
request to issue 1234.  And when we merge the pull request, Github will
automatically close the issue.
-->

- Related Issue #
- Closes #4959 (thanks @coder543)
This commit is contained in:
blessedcoolant 2023-10-20 11:04:34 +05:30 committed by GitHub
commit 02928298d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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