config_mode.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. from collections.abc import Mapping
  2. from typing import TYPE_CHECKING, Any, TypeVar, Union
  3. from attrs import define as _attrs_define
  4. from attrs import field as _attrs_field
  5. from ..types import UNSET, Unset
  6. if TYPE_CHECKING:
  7. from ..models.agent_config import AgentConfig
  8. T = TypeVar("T", bound="ConfigMode")
  9. @_attrs_define
  10. class ConfigMode:
  11. """@deprecated Use `agent` field instead.
  12. Attributes:
  13. build (Union[Unset, AgentConfig]):
  14. plan (Union[Unset, AgentConfig]):
  15. """
  16. build: Union[Unset, "AgentConfig"] = UNSET
  17. plan: Union[Unset, "AgentConfig"] = UNSET
  18. additional_properties: dict[str, "AgentConfig"] = _attrs_field(init=False, factory=dict)
  19. def to_dict(self) -> dict[str, Any]:
  20. build: Union[Unset, dict[str, Any]] = UNSET
  21. if not isinstance(self.build, Unset):
  22. build = self.build.to_dict()
  23. plan: Union[Unset, dict[str, Any]] = UNSET
  24. if not isinstance(self.plan, Unset):
  25. plan = self.plan.to_dict()
  26. field_dict: dict[str, Any] = {}
  27. for prop_name, prop in self.additional_properties.items():
  28. field_dict[prop_name] = prop.to_dict()
  29. field_dict.update({})
  30. if build is not UNSET:
  31. field_dict["build"] = build
  32. if plan is not UNSET:
  33. field_dict["plan"] = plan
  34. return field_dict
  35. @classmethod
  36. def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
  37. from ..models.agent_config import AgentConfig
  38. d = dict(src_dict)
  39. _build = d.pop("build", UNSET)
  40. build: Union[Unset, AgentConfig]
  41. if isinstance(_build, Unset):
  42. build = UNSET
  43. else:
  44. build = AgentConfig.from_dict(_build)
  45. _plan = d.pop("plan", UNSET)
  46. plan: Union[Unset, AgentConfig]
  47. if isinstance(_plan, Unset):
  48. plan = UNSET
  49. else:
  50. plan = AgentConfig.from_dict(_plan)
  51. config_mode = cls(
  52. build=build,
  53. plan=plan,
  54. )
  55. additional_properties = {}
  56. for prop_name, prop_dict in d.items():
  57. additional_property = AgentConfig.from_dict(prop_dict)
  58. additional_properties[prop_name] = additional_property
  59. config_mode.additional_properties = additional_properties
  60. return config_mode
  61. @property
  62. def additional_keys(self) -> list[str]:
  63. return list(self.additional_properties.keys())
  64. def __getitem__(self, key: str) -> "AgentConfig":
  65. return self.additional_properties[key]
  66. def __setitem__(self, key: str, value: "AgentConfig") -> None:
  67. self.additional_properties[key] = value
  68. def __delitem__(self, key: str) -> None:
  69. del self.additional_properties[key]
  70. def __contains__(self, key: str) -> bool:
  71. return key in self.additional_properties