Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor: replace bare dict with dict[str, Any] in tools message_transformer (#35069)

wdeveloper1633c4e512f19e
diff --git a/api/core/tools/utils/message_transformer.py b/api/core/tools/utils/message_transformer.py
index 2264981abd5..81c85bc90de 100644
--- a/api/core/tools/utils/message_transformer.py
+++ b/api/core/tools/utils/message_transformer.py
@@ -4,6 +4,7 @@ from collections.abc import Generator
from datetime import date, datetime
from decimal import Decimal
from mimetypes import guess_extension
+from typing import Any
from uuid import UUID
import numpy as np
@@ -50,7 +51,7 @@ def safe_json_value(v):
return v
-def safe_json_dict(d: dict):
+def safe_json_dict(d: dict[str, Any]):
if not isinstance(d, dict):
raise TypeError("safe_json_dict() expects a dictionary (dict) as input")
return {k: safe_json_value(v) for k, v in d.items()}
@@ -196,11 +197,11 @@ class ToolFileMessageTransformer:
@staticmethod
def _with_tool_file_meta(
- meta: dict | None,
+ meta: dict[str, Any] | None,
*,
tool_file_id: str | None = None,
url: str | None = None,
- ) -> dict:
+ ) -> dict[str, Any]:
normalized_meta = meta.copy() if meta is not None else {}
resolved_tool_file_id = tool_file_id or ToolFileMessageTransformer._extract_tool_file_id(url)
if resolved_tool_file_id and "tool_file_id" not in normalized_meta: