defto_dict(self)->dict[str,t.Any]:"""Convert the model to a dict Returns ------- t.Dict[str, Any] The model as a dict. """returnattrs.asdict(self,filter=attrs.filters.exclude(attrs.fields(BaseModel).raw),value_serializer=_serializer)
@classmethoddeffrom_payload(cls,payload:dict[str,t.Any])->Self:"""Create a model from a payload Parameters ---------- payload: t.Dict[str, Any] The payload to create the model from. Returns ------- BaseModel The model created from the payload. """returncls(raw=payload)