feat: mypy for all type check (#10921)
This commit is contained in:
parent
c91e8b1737
commit
56e15d09a9
584 changed files with 3975 additions and 2826 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import base64
|
||||
from collections.abc import Mapping
|
||||
|
||||
from configs import dify_config
|
||||
from core.helper import ssrf_proxy
|
||||
|
|
@ -55,7 +56,7 @@ def to_prompt_message_content(
|
|||
if f.type == FileType.IMAGE:
|
||||
params["detail"] = image_detail_config or ImagePromptMessageContent.DETAIL.LOW
|
||||
|
||||
prompt_class_map = {
|
||||
prompt_class_map: Mapping[FileType, type[MultiModalPromptMessageContent]] = {
|
||||
FileType.IMAGE: ImagePromptMessageContent,
|
||||
FileType.AUDIO: AudioPromptMessageContent,
|
||||
FileType.VIDEO: VideoPromptMessageContent,
|
||||
|
|
@ -63,7 +64,7 @@ def to_prompt_message_content(
|
|||
}
|
||||
|
||||
try:
|
||||
return prompt_class_map[f.type](**params)
|
||||
return prompt_class_map[f.type].model_validate(params)
|
||||
except KeyError:
|
||||
raise ValueError(f"file type {f.type} is not supported")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from typing import TYPE_CHECKING, Any
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.tools.tool_file_manager import ToolFileManager
|
||||
|
|
@ -9,4 +9,4 @@ tool_file_manager: dict[str, Any] = {"manager": None}
|
|||
class ToolFileParser:
|
||||
@staticmethod
|
||||
def get_tool_file_manager() -> "ToolFileManager":
|
||||
return tool_file_manager["manager"]
|
||||
return cast("ToolFileManager", tool_file_manager["manager"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue