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

This commit is contained in:
YBoy 2026-04-11 02:37:10 +02:00 committed by GitHub
parent f962e61315
commit 992ac38d0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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):