refactor(api): type ToolInvokeMeta.to_dict with TypedDict (#34942)

This commit is contained in:
YBoy
2026-04-11 00:37:10 +00:00
committed by GitHub
parent f962e61315
commit 992ac38d0d
+9 -2
View File
@@ -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):