Action result
| 333 | transform_info: Optional[Dict[str, Any]] = Field(default=None, description="Transform information") |
| 334 | |
| 335 | class ActionResult(BaseModel): |
| 336 | """Action result""" |
| 337 | model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow") |
| 338 | |
| 339 | success: bool = Field(description="Whether the action was successful") |
| 340 | message: str = Field(description="The message of the action result") |
| 341 | extra: Optional[Dict[str, Any]] = Field(default=None, description="The extra information of the action result") |
| 342 | |
| 343 | def __str__(self) -> str: |
| 344 | return f"ActionResult(success={self.success}, message={self.message}, extra={self.extra})" |
| 345 | |
| 346 | def __repr__(self) -> str: |
| 347 | return self.__str__() |
| 348 | |
| 349 | def model_dump(self, **kwargs) -> Dict[str, Any]: |
| 350 | """Dump the model to a dictionary, recursively serializing nested Pydantic models.""" |
| 351 | from pydantic import BaseModel |
| 352 | |
| 353 | def serialize_value(value: Any) -> Any: |
| 354 | if isinstance(value, BaseModel): |
| 355 | return value.model_dump(**kwargs) |
| 356 | if isinstance(value, list): |
| 357 | return [serialize_value(item) for item in value] |
| 358 | if isinstance(value, dict): |
| 359 | return {k: serialize_value(v) for k, v in value.items()} |
| 360 | return value |
| 361 | |
| 362 | return { |
| 363 | "success": self.success, |
| 364 | "message": self.message, |
| 365 | "extra": serialize_value(self.extra) if self.extra is not None else None, |
| 366 | } |
| 367 | |
| 368 | def model_dump_json(self) -> str: |
| 369 | return json.dumps(self.model_dump()) |
| 370 | |
| 371 | class EnvironmentState(BaseModel): |
| 372 | """Environment state""" |
no outgoing calls
no test coverage detected