mirror of
https://github.com/langgenius/dify.git
synced 2026-04-16 02:16:57 +08:00
refactor(api): type ToolInvokeMeta.to_dict with TypedDict (#34942)
This commit is contained in:
parent
f962e61315
commit
992ac38d0d
@ -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):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user