mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 23:18:05 +08:00
remove bare list, dict, Sequence, None, Any (#25058)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
@ -6,7 +6,7 @@ from models.account import Tenant
|
||||
|
||||
class PluginEncrypter:
|
||||
@classmethod
|
||||
def invoke_encrypt(cls, tenant: Tenant, payload: RequestInvokeEncrypt) -> dict:
|
||||
def invoke_encrypt(cls, tenant: Tenant, payload: RequestInvokeEncrypt):
|
||||
encrypter, cache = create_provider_encrypter(
|
||||
tenant_id=tenant.id,
|
||||
config=payload.config,
|
||||
|
||||
@ -27,7 +27,7 @@ class PluginNodeBackwardsInvocation(BaseBackwardsInvocation):
|
||||
model_config: ParameterExtractorModelConfig,
|
||||
instruction: str,
|
||||
query: str,
|
||||
) -> dict:
|
||||
):
|
||||
"""
|
||||
Invoke parameter extractor node.
|
||||
|
||||
@ -78,7 +78,7 @@ class PluginNodeBackwardsInvocation(BaseBackwardsInvocation):
|
||||
classes: list[ClassConfig],
|
||||
instruction: str,
|
||||
query: str,
|
||||
) -> dict:
|
||||
):
|
||||
"""
|
||||
Invoke question classifier node.
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ class PluginDeclaration(BaseModel):
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def validate_category(cls, values: dict) -> dict:
|
||||
def validate_category(cls, values: dict):
|
||||
# auto detect category
|
||||
if values.get("tool"):
|
||||
values["category"] = PluginCategory.Tool
|
||||
@ -168,7 +168,7 @@ class GenericProviderID:
|
||||
def __str__(self) -> str:
|
||||
return f"{self.organization}/{self.plugin_name}/{self.provider_name}"
|
||||
|
||||
def __init__(self, value: str, is_hardcoded: bool = False) -> None:
|
||||
def __init__(self, value: str, is_hardcoded: bool = False):
|
||||
if not value:
|
||||
raise NotFound("plugin not found, please add plugin")
|
||||
# check if the value is a valid plugin id with format: $organization/$plugin_name/$provider_name
|
||||
@ -191,14 +191,14 @@ class GenericProviderID:
|
||||
|
||||
|
||||
class ModelProviderID(GenericProviderID):
|
||||
def __init__(self, value: str, is_hardcoded: bool = False) -> None:
|
||||
def __init__(self, value: str, is_hardcoded: bool = False):
|
||||
super().__init__(value, is_hardcoded)
|
||||
if self.organization == "langgenius" and self.provider_name == "google":
|
||||
self.plugin_name = "gemini"
|
||||
|
||||
|
||||
class ToolProviderID(GenericProviderID):
|
||||
def __init__(self, value: str, is_hardcoded: bool = False) -> None:
|
||||
def __init__(self, value: str, is_hardcoded: bool = False):
|
||||
super().__init__(value, is_hardcoded)
|
||||
if self.organization == "langgenius":
|
||||
if self.provider_name in ["jina", "siliconflow", "stepfun", "gitee_ai"]:
|
||||
|
||||
@ -17,7 +17,7 @@ class PluginAgentClient(BasePluginClient):
|
||||
Fetch agent providers for the given tenant.
|
||||
"""
|
||||
|
||||
def transformer(json_response: dict[str, Any]) -> dict:
|
||||
def transformer(json_response: dict[str, Any]):
|
||||
for provider in json_response.get("data", []):
|
||||
declaration = provider.get("declaration", {}) or {}
|
||||
provider_name = declaration.get("identity", {}).get("name")
|
||||
@ -49,7 +49,7 @@ class PluginAgentClient(BasePluginClient):
|
||||
"""
|
||||
agent_provider_id = GenericProviderID(provider)
|
||||
|
||||
def transformer(json_response: dict[str, Any]) -> dict:
|
||||
def transformer(json_response: dict[str, Any]):
|
||||
# skip if error occurs
|
||||
if json_response.get("data") is None or json_response.get("data", {}).get("declaration") is None:
|
||||
return json_response
|
||||
|
||||
@ -8,7 +8,7 @@ from extensions.ext_logging import get_request_id
|
||||
class PluginDaemonError(Exception):
|
||||
"""Base class for all plugin daemon errors."""
|
||||
|
||||
def __init__(self, description: str) -> None:
|
||||
def __init__(self, description: str):
|
||||
self.description = description
|
||||
|
||||
def __str__(self) -> str:
|
||||
|
||||
@ -415,7 +415,7 @@ class PluginModelClient(BasePluginClient):
|
||||
model: str,
|
||||
credentials: dict,
|
||||
language: Optional[str] = None,
|
||||
) -> list[dict]:
|
||||
):
|
||||
"""
|
||||
Get tts model voices
|
||||
"""
|
||||
|
||||
@ -16,7 +16,7 @@ class PluginToolManager(BasePluginClient):
|
||||
Fetch tool providers for the given tenant.
|
||||
"""
|
||||
|
||||
def transformer(json_response: dict[str, Any]) -> dict:
|
||||
def transformer(json_response: dict[str, Any]):
|
||||
for provider in json_response.get("data", []):
|
||||
declaration = provider.get("declaration", {}) or {}
|
||||
provider_name = declaration.get("identity", {}).get("name")
|
||||
@ -48,7 +48,7 @@ class PluginToolManager(BasePluginClient):
|
||||
"""
|
||||
tool_provider_id = ToolProviderID(provider)
|
||||
|
||||
def transformer(json_response: dict[str, Any]) -> dict:
|
||||
def transformer(json_response: dict[str, Any]):
|
||||
data = json_response.get("data")
|
||||
if data:
|
||||
for tool in data.get("declaration", {}).get("tools", []):
|
||||
|
||||
@ -18,7 +18,7 @@ class FileChunk:
|
||||
bytes_written: int = field(default=0, init=False)
|
||||
data: bytearray = field(init=False)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
def __post_init__(self):
|
||||
self.data = bytearray(self.total_length)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user