mirror of
https://github.com/langgenius/dify.git
synced 2026-08-28 21:23:22 +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")
|
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):
|
class ToolInvokeMeta(BaseModel):
|
||||||
"""
|
"""
|
||||||
Tool invoke meta
|
Tool invoke meta
|
||||||
@ -473,12 +479,13 @@ class ToolInvokeMeta(BaseModel):
|
|||||||
"""
|
"""
|
||||||
return cls(time_cost=0.0, error=error, tool_config={})
|
return cls(time_cost=0.0, error=error, tool_config={})
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self) -> ToolInvokeMetaDict:
|
||||||
return {
|
result: ToolInvokeMetaDict = {
|
||||||
"time_cost": self.time_cost,
|
"time_cost": self.time_cost,
|
||||||
"error": self.error,
|
"error": self.error,
|
||||||
"tool_config": self.tool_config,
|
"tool_config": self.tool_config,
|
||||||
}
|
}
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class ToolLabel(BaseModel):
|
class ToolLabel(BaseModel):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user