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(api): type ToolInvokeMeta.to_dict with TypedDict (#34942)

YBoy992ac38d0d33
diff --git a/api/core/tools/entities/tool_entities.py b/api/core/tools/entities/tool_entities.py
index 31e879add24..b4253652f99 100644
--- a/api/core/tools/entities/tool_entities.py
+++ b/api/core/tools/entities/tool_entities.py
@@ -450,6 +450,12 @@ class WorkflowToolParameterConfiguration(BaseModel):
form: ToolParameter.ToolParameterForm = Field(..., description="The form of the parameter")
+class ToolInvokeMetaDict(TypedDict):
+ time_cost: float
+ error: str | None
+ tool_config: dict[str, Any] | None
+
+
class ToolInvokeMeta(BaseModel):
"""
Tool invoke meta
@@ -473,12 +479,13 @@ class ToolInvokeMeta(BaseModel):
"""
return cls(time_cost=0.0, error=error, tool_config={})
- def to_dict(self):
- return {
+ def to_dict(self) -> ToolInvokeMetaDict:
+ result: ToolInvokeMetaDict = {
"time_cost": self.time_cost,
"error": self.error,
"tool_config": self.tool_config,
}
+ return result
class ToolLabel(BaseModel):