mirror of
https://github.com/langgenius/dify.git
synced 2026-04-30 07:28:05 +08:00
feat: plugin migrations
This commit is contained in:
@ -2,7 +2,7 @@ from collections.abc import Sequence
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
from core.model_runtime.entities.common_entities import I18nObject
|
||||
from core.model_runtime.entities.model_entities import AIModelEntity, ModelType
|
||||
@ -134,6 +134,14 @@ class ProviderEntity(BaseModel):
|
||||
# pydantic configs
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
@field_validator("models", mode="before")
|
||||
@classmethod
|
||||
def validate_models(cls, v):
|
||||
# returns EmptyList if v is empty
|
||||
if not v:
|
||||
return []
|
||||
return v
|
||||
|
||||
def to_simple_provider(self) -> SimpleProviderEntity:
|
||||
"""
|
||||
Convert to simple provider.
|
||||
|
||||
@ -76,7 +76,11 @@ class PluginInstallationManager(BasePluginManager):
|
||||
)
|
||||
|
||||
def install_from_identifiers(
|
||||
self, tenant_id: str, identifiers: Sequence[str], source: PluginInstallationSource, meta: dict
|
||||
self,
|
||||
tenant_id: str,
|
||||
identifiers: Sequence[str],
|
||||
source: PluginInstallationSource,
|
||||
metas: list[dict],
|
||||
) -> PluginInstallTaskStartResponse:
|
||||
"""
|
||||
Install a plugin from an identifier.
|
||||
@ -89,7 +93,7 @@ class PluginInstallationManager(BasePluginManager):
|
||||
data={
|
||||
"plugin_unique_identifiers": identifiers,
|
||||
"source": source,
|
||||
"meta": meta,
|
||||
"metas": metas,
|
||||
},
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user