diff --git a/modules/api/models.py b/modules/api/models.py index b5683071..b55fa728 100644 --- a/modules/api/models.py +++ b/modules/api/models.py @@ -1,4 +1,6 @@ import inspect +import types + from pydantic import BaseModel, Field, create_model from typing import Any, Optional from typing_extensions import Literal @@ -207,11 +209,14 @@ class PreprocessResponse(BaseModel): fields = {} for key, metadata in opts.data_labels.items(): value = opts.data.get(key) + if key == 'sd_model_checkpoint': + value = None optType = opts.typemap.get(type(metadata.default), type(value)) - if (metadata is not None): - fields.update({key: (Optional[optType], Field( - default=metadata.default ,description=metadata.label))}) + if optType == types.NoneType: + pass + elif metadata is not None: + fields.update({key: (Optional[optType], Field(default=metadata.default, description=metadata.label))}) else: fields.update({key: (Optional[optType], Field())})