also make None a valid option for options API for #11854

This commit is contained in:
AUTOMATIC1111 2023-07-18 11:48:40 +03:00
parent 6be5ccb530
commit 420cc8f68e

View File

@ -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())})