mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 14:49:18 +08:00
fix: riff
This commit is contained in:
parent
5ff9cee326
commit
49bd1a7a49
@ -1,4 +1,4 @@
|
||||
from enum import Enum
|
||||
from enum import StrEnum
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
@ -6,7 +6,7 @@ from core.plugin.entities.plugin import PluginDeclaration, PluginInstallationSou
|
||||
|
||||
|
||||
class PluginBundleDependency(BaseModel):
|
||||
class Type(str, Enum):
|
||||
class Type(StrEnum):
|
||||
Github = PluginInstallationSource.Github.value
|
||||
Marketplace = PluginInstallationSource.Marketplace.value
|
||||
Package = PluginInstallationSource.Package.value
|
||||
|
@ -1,7 +1,7 @@
|
||||
import datetime
|
||||
import enum
|
||||
import re
|
||||
from collections.abc import Mapping
|
||||
from enum import Enum
|
||||
from typing import Any, Optional
|
||||
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
@ -13,7 +13,7 @@ from core.tools.entities.common_entities import I18nObject
|
||||
from core.tools.entities.tool_entities import ToolProviderEntity
|
||||
|
||||
|
||||
class PluginInstallationSource(str, Enum):
|
||||
class PluginInstallationSource(enum.StrEnum):
|
||||
Github = "github"
|
||||
Marketplace = "marketplace"
|
||||
Package = "package"
|
||||
@ -55,7 +55,7 @@ class PluginResourceRequirements(BaseModel):
|
||||
permission: Optional[Permission]
|
||||
|
||||
|
||||
class PluginCategory(str, Enum):
|
||||
class PluginCategory(enum.StrEnum):
|
||||
Tool = "tool"
|
||||
Model = "model"
|
||||
Extension = "extension"
|
||||
@ -163,7 +163,7 @@ class GenericProviderID:
|
||||
|
||||
|
||||
class PluginDependency(BaseModel):
|
||||
class Type(str, Enum):
|
||||
class Type(enum.StrEnum):
|
||||
Github = PluginInstallationSource.Github.value
|
||||
Marketplace = PluginInstallationSource.Marketplace.value
|
||||
Package = PluginInstallationSource.Package.value
|
||||
|
@ -1,3 +1,4 @@
|
||||
import enum
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import Generic, Optional, TypeVar
|
||||
@ -119,7 +120,7 @@ class PluginDaemonInnerError(Exception):
|
||||
self.message = message
|
||||
|
||||
|
||||
class PluginInstallTaskStatus(str, Enum):
|
||||
class PluginInstallTaskStatus(enum.StrEnum):
|
||||
Pending = "pending"
|
||||
Running = "running"
|
||||
Success = "success"
|
||||
|
@ -1,4 +1,5 @@
|
||||
import base64
|
||||
import enum
|
||||
from enum import Enum
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
@ -33,7 +34,7 @@ class ToolLabelEnum(Enum):
|
||||
OTHER = "other"
|
||||
|
||||
|
||||
class ToolProviderType(str, Enum):
|
||||
class ToolProviderType(enum.StrEnum):
|
||||
"""
|
||||
Enum class for tool provider
|
||||
"""
|
||||
@ -205,7 +206,7 @@ class ToolParameterOption(BaseModel):
|
||||
|
||||
|
||||
class ToolParameter(BaseModel):
|
||||
class ToolParameterType(str, Enum):
|
||||
class ToolParameterType(enum.StrEnum):
|
||||
STRING = CommonParameterType.STRING.value
|
||||
NUMBER = CommonParameterType.NUMBER.value
|
||||
BOOLEAN = CommonParameterType.BOOLEAN.value
|
||||
|
@ -142,7 +142,9 @@ class TenantAccountRole(enum.StrEnum):
|
||||
|
||||
@staticmethod
|
||||
def is_valid_role(role: str) -> bool:
|
||||
return role and role in {
|
||||
if not role:
|
||||
return False
|
||||
return role in {
|
||||
TenantAccountRole.OWNER,
|
||||
TenantAccountRole.ADMIN,
|
||||
TenantAccountRole.EDITOR,
|
||||
@ -152,15 +154,21 @@ class TenantAccountRole(enum.StrEnum):
|
||||
|
||||
@staticmethod
|
||||
def is_privileged_role(role: str) -> bool:
|
||||
return role and role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN}
|
||||
if not role:
|
||||
return False
|
||||
return role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN}
|
||||
|
||||
@staticmethod
|
||||
def is_admin_role(role: str) -> bool:
|
||||
return role and role == TenantAccountRole.ADMIN
|
||||
if not role:
|
||||
return False
|
||||
return role == TenantAccountRole.ADMIN
|
||||
|
||||
@staticmethod
|
||||
def is_non_owner_role(role: str) -> bool:
|
||||
return role and role in {
|
||||
if not role:
|
||||
return False
|
||||
return role in {
|
||||
TenantAccountRole.ADMIN,
|
||||
TenantAccountRole.EDITOR,
|
||||
TenantAccountRole.NORMAL,
|
||||
@ -169,11 +177,15 @@ class TenantAccountRole(enum.StrEnum):
|
||||
|
||||
@staticmethod
|
||||
def is_editing_role(role: str) -> bool:
|
||||
return role and role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN, TenantAccountRole.EDITOR}
|
||||
if not role:
|
||||
return False
|
||||
return role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN, TenantAccountRole.EDITOR}
|
||||
|
||||
@staticmethod
|
||||
def is_dataset_edit_role(role: str) -> bool:
|
||||
return role and role in {
|
||||
if not role:
|
||||
return False
|
||||
return role in {
|
||||
TenantAccountRole.OWNER,
|
||||
TenantAccountRole.ADMIN,
|
||||
TenantAccountRole.EDITOR,
|
||||
@ -273,12 +285,12 @@ class InvitationCode(db.Model):
|
||||
|
||||
|
||||
class TenantPluginPermission(Base):
|
||||
class InstallPermission(str, enum.Enum):
|
||||
class InstallPermission(enum.StrEnum):
|
||||
EVERYONE = "everyone"
|
||||
ADMINS = "admins"
|
||||
NOBODY = "noone"
|
||||
|
||||
class DebugPermission(str, enum.Enum):
|
||||
class DebugPermission(enum.StrEnum):
|
||||
EVERYONE = "everyone"
|
||||
ADMINS = "admins"
|
||||
NOBODY = "noone"
|
||||
|
Loading…
x
Reference in New Issue
Block a user