1- from typing import TYPE_CHECKING , Any , Dict , List , Type , TypeVar , Union
1+ from typing import TYPE_CHECKING , Any , Dict , List , Type , TypeVar , Union , cast
22
33from attrs import define as _attrs_define
44from attrs import field as _attrs_field
55
66from ..types import UNSET , Unset
77
88if TYPE_CHECKING :
9- from ..models .history_event_parsed_output import HistoryEventParsedOutput
9+ from ..models .any_object import AnyObject
1010 from ..models .history_event_prompt import HistoryEventPrompt
1111 from ..models .history_event_reasks_item import HistoryEventReasksItem
12- from ..models .history_event_validated_output import HistoryEventValidatedOutput
1312
1413
1514T = TypeVar ("T" , bound = "HistoryEvent" )
@@ -21,28 +20,34 @@ class HistoryEvent:
2120 Attributes:
2221 instructions (Union[Unset, str]):
2322 output (Union[Unset, str]):
24- parsed_output (Union[Unset, HistoryEventParsedOutput ]):
23+ parsed_output (Union['AnyObject', Unset, str ]):
2524 prompt (Union[Unset, HistoryEventPrompt]):
2625 reasks (Union[Unset, List['HistoryEventReasksItem']]):
27- validated_output (Union[Unset, HistoryEventValidatedOutput ]):
26+ validated_output (Union['AnyObject', Unset, str ]):
2827 """
2928
3029 instructions : Union [Unset , str ] = UNSET
3130 output : Union [Unset , str ] = UNSET
32- parsed_output : Union [Unset , "HistoryEventParsedOutput" ] = UNSET
31+ parsed_output : Union ["AnyObject" , Unset , str ] = UNSET
3332 prompt : Union [Unset , "HistoryEventPrompt" ] = UNSET
3433 reasks : Union [Unset , List ["HistoryEventReasksItem" ]] = UNSET
35- validated_output : Union [Unset , "HistoryEventValidatedOutput" ] = UNSET
34+ validated_output : Union ["AnyObject" , Unset , str ] = UNSET
3635 additional_properties : Dict [str , Any ] = _attrs_field (init = False , factory = dict )
3736
3837 def to_dict (self ) -> Dict [str , Any ]:
38+ from ..models .any_object import AnyObject
39+
3940 instructions = self .instructions
4041
4142 output = self .output
4243
43- parsed_output : Union [Unset , Dict [str , Any ]] = UNSET
44- if not isinstance (self .parsed_output , Unset ):
44+ parsed_output : Union [Dict [str , Any ], Unset , str ]
45+ if isinstance (self .parsed_output , Unset ):
46+ parsed_output = UNSET
47+ elif isinstance (self .parsed_output , AnyObject ):
4548 parsed_output = self .parsed_output .to_dict ()
49+ else :
50+ parsed_output = self .parsed_output
4651
4752 prompt : Union [Unset , Dict [str , Any ]] = UNSET
4853 if not isinstance (self .prompt , Unset ):
@@ -55,9 +60,13 @@ def to_dict(self) -> Dict[str, Any]:
5560 reasks_item = reasks_item_data .to_dict ()
5661 reasks .append (reasks_item )
5762
58- validated_output : Union [Unset , Dict [str , Any ]] = UNSET
59- if not isinstance (self .validated_output , Unset ):
63+ validated_output : Union [Dict [str , Any ], Unset , str ]
64+ if isinstance (self .validated_output , Unset ):
65+ validated_output = UNSET
66+ elif isinstance (self .validated_output , AnyObject ):
6067 validated_output = self .validated_output .to_dict ()
68+ else :
69+ validated_output = self .validated_output
6170
6271 field_dict : Dict [str , Any ] = {}
6372 field_dict .update (self .additional_properties )
@@ -79,22 +88,29 @@ def to_dict(self) -> Dict[str, Any]:
7988
8089 @classmethod
8190 def from_dict (cls : Type [T ], src_dict : Dict [str , Any ]) -> T :
82- from ..models .history_event_parsed_output import HistoryEventParsedOutput
91+ from ..models .any_object import AnyObject
8392 from ..models .history_event_prompt import HistoryEventPrompt
8493 from ..models .history_event_reasks_item import HistoryEventReasksItem
85- from ..models .history_event_validated_output import HistoryEventValidatedOutput
8694
8795 d = src_dict .copy ()
8896 instructions = d .pop ("instructions" , UNSET )
8997
9098 output = d .pop ("output" , UNSET )
9199
92- _parsed_output = d .pop ("parsedOutput" , UNSET )
93- parsed_output : Union [Unset , HistoryEventParsedOutput ]
94- if isinstance (_parsed_output , Unset ):
95- parsed_output = UNSET
96- else :
97- parsed_output = HistoryEventParsedOutput .from_dict (_parsed_output )
100+ def _parse_parsed_output (data : object ) -> Union ["AnyObject" , Unset , str ]:
101+ if isinstance (data , Unset ):
102+ return data
103+ try :
104+ if not isinstance (data , dict ):
105+ raise TypeError ()
106+ parsed_output_type_0 = AnyObject .from_dict (data )
107+
108+ return parsed_output_type_0
109+ except : # noqa: E722
110+ pass
111+ return cast (Union ["AnyObject" , Unset , str ], data )
112+
113+ parsed_output = _parse_parsed_output (d .pop ("parsedOutput" , UNSET ))
98114
99115 _prompt = d .pop ("prompt" , UNSET )
100116 prompt : Union [Unset , HistoryEventPrompt ]
@@ -110,12 +126,20 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
110126
111127 reasks .append (reasks_item )
112128
113- _validated_output = d .pop ("validatedOutput" , UNSET )
114- validated_output : Union [Unset , HistoryEventValidatedOutput ]
115- if isinstance (_validated_output , Unset ):
116- validated_output = UNSET
117- else :
118- validated_output = HistoryEventValidatedOutput .from_dict (_validated_output )
129+ def _parse_validated_output (data : object ) -> Union ["AnyObject" , Unset , str ]:
130+ if isinstance (data , Unset ):
131+ return data
132+ try :
133+ if not isinstance (data , dict ):
134+ raise TypeError ()
135+ validated_output_type_0 = AnyObject .from_dict (data )
136+
137+ return validated_output_type_0
138+ except : # noqa: E722
139+ pass
140+ return cast (Union ["AnyObject" , Unset , str ], data )
141+
142+ validated_output = _parse_validated_output (d .pop ("validatedOutput" , UNSET ))
119143
120144 history_event = cls (
121145 instructions = instructions ,
0 commit comments