diff --git a/invokeai/app/api/routers/model_manager.py b/invokeai/app/api/routers/model_manager.py index 8b66c70618..38fc308e9c 100644 --- a/invokeai/app/api/routers/model_manager.py +++ b/invokeai/app/api/routers/model_manager.py @@ -267,11 +267,15 @@ async def update_model_metadata( try: original_metadata = record_store.get_metadata(key) if original_metadata: - original_metadata.trigger_phrases = changes.trigger_phrases + if changes.trigger_phrases: + original_metadata.trigger_phrases = changes.trigger_phrases + + if changes.default_settings: + original_metadata.default_settings = changes.default_settings metadata_store.update_metadata(key, original_metadata) else: - metadata_store.add_metadata(key, BaseMetadata(name="", author="",trigger_phrases=changes.trigger_phrases)) + metadata_store.add_metadata(key, BaseMetadata(name="", author="",trigger_phrases=changes.trigger_phrases, default_settings=changes.default_settings)) except Exception as e: raise HTTPException( status_code=500, diff --git a/invokeai/app/services/model_metadata/metadata_store_base.py b/invokeai/app/services/model_metadata/metadata_store_base.py index e0ae34378b..665e2d6007 100644 --- a/invokeai/app/services/model_metadata/metadata_store_base.py +++ b/invokeai/app/services/model_metadata/metadata_store_base.py @@ -10,17 +10,22 @@ from pydantic import Field from invokeai.app.util.model_exclude_null import BaseModelExcludeNull from invokeai.backend.model_manager.metadata import AnyModelRepoMetadata +from invokeai.backend.model_manager.metadata.metadata_base import ModelDefaultSettings class ModelMetadataChanges(BaseModelExcludeNull, extra="allow"): """A set of changes to apply to model metadata. Only limited changes are valid: - `trigger_phrases`: the list of trigger phrases for this model + - `default_settings`: the user-configured default settings for this model """ trigger_phrases: Optional[List[str]] = Field(default=None, description="The model's list of trigger phrases") """The model's list of trigger phrases""" + default_settings: Optional[ModelDefaultSettings] = Field(default=None, description="The user-configured default settings for this model") + """The user-configured default settings for this model""" + class ModelMetadataStoreBase(ABC): """Store, search and fetch model metadata retrieved from remote repositories.""" diff --git a/invokeai/backend/model_manager/metadata/metadata_base.py b/invokeai/backend/model_manager/metadata/metadata_base.py index 502467a0af..bfeac3251e 100644 --- a/invokeai/backend/model_manager/metadata/metadata_base.py +++ b/invokeai/backend/model_manager/metadata/metadata_base.py @@ -24,6 +24,7 @@ from pydantic import BaseModel, Field, TypeAdapter from pydantic.networks import AnyHttpUrl from requests.sessions import Session from typing_extensions import Annotated +from invokeai.app.invocations.constants import SCHEDULER_NAME_VALUES from invokeai.backend.model_manager import ModelRepoVariant @@ -68,6 +69,14 @@ class RemoteModelFile(BaseModel): sha256: Optional[str] = Field(description="SHA256 hash of this model (not always available)", default=None) +class ModelDefaultSettings(BaseModel): + vae: str | None + vae_precision: str | None + scheduler: SCHEDULER_NAME_VALUES | None + steps: int | None + cfg_scale: float | None + cfg_rescale_multiplier: float | None + class ModelMetadataBase(BaseModel): """Base class for model metadata information.""" @@ -75,6 +84,7 @@ class ModelMetadataBase(BaseModel): author: str = Field(description="model's author") tags: Optional[Set[str]] = Field(description="tags provided by model source", default=None) trigger_phrases: Optional[List[str]] = Field(description="trigger phrases for this model", default=None) + default_settings: Optional[ModelDefaultSettings] = Field(description="default settings for this model", default=None) class BaseMetadata(ModelMetadataBase):