mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-17 20:43:33 -05:00
feat: move workflow/metadata models to baseinvocation.py
needed to prevent circular imports
This commit is contained in:
@@ -15,7 +15,6 @@ from pydantic.fields import _Unset
|
||||
from pydantic_core import PydanticUndefined
|
||||
|
||||
from invokeai.app.services.config.config_default import InvokeAIAppConfig
|
||||
from invokeai.app.services.workflow_records.workflow_records_common import WorkflowField
|
||||
from invokeai.app.util.misc import uuid_string
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -813,22 +812,29 @@ def invocation_output(
|
||||
return wrapper
|
||||
|
||||
|
||||
class WorkflowField(RootModel):
|
||||
"""
|
||||
Pydantic model for workflows with custom root of type dict[str, Any].
|
||||
Workflows are stored without a strict schema.
|
||||
"""
|
||||
|
||||
root: dict[str, Any] = Field(description="The workflow")
|
||||
|
||||
|
||||
type_adapter_WorkflowField = TypeAdapter(WorkflowField)
|
||||
|
||||
|
||||
class WithWorkflow(BaseModel):
|
||||
workflow: Optional[WorkflowField] = InputField(default=None, description=FieldDescriptions.workflow)
|
||||
|
||||
|
||||
class MetadataItemField(BaseModel):
|
||||
label: str = Field(description=FieldDescriptions.metadata_item_label)
|
||||
value: Any = Field(description=FieldDescriptions.metadata_item_value)
|
||||
|
||||
|
||||
class MetadataField(RootModel):
|
||||
"""
|
||||
Pydantic model for metadata with custom root of type dict[str, Any].
|
||||
Metadata is stored without a strict schema.
|
||||
"""
|
||||
|
||||
root: dict[str, Any] = Field(description="A dictionary of metadata, shape of which is arbitrary")
|
||||
root: dict[str, Any] = Field(description="The metadata")
|
||||
|
||||
|
||||
type_adapter_MetadataField = TypeAdapter(MetadataField)
|
||||
|
||||
@@ -9,7 +9,6 @@ from invokeai.app.invocations.baseinvocation import (
|
||||
InputField,
|
||||
InvocationContext,
|
||||
MetadataField,
|
||||
MetadataItemField,
|
||||
OutputField,
|
||||
UIType,
|
||||
invocation,
|
||||
@@ -24,6 +23,11 @@ from invokeai.app.invocations.t2i_adapter import T2IAdapterField
|
||||
from ...version import __version__
|
||||
|
||||
|
||||
class MetadataItemField(BaseModel):
|
||||
label: str = Field(description=FieldDescriptions.metadata_item_label)
|
||||
value: Any = Field(description=FieldDescriptions.metadata_item_value)
|
||||
|
||||
|
||||
class LoRAMetadataField(BaseModel):
|
||||
"""LoRA Metadata Field"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user