@@ -60,9 +60,12 @@ def __post_init__(self):
6060 if self .role is not None and (self .role == 'AIMessageChunk' or self .role == 'ai' ):
6161 self .role = 'assistant'
6262 parts : Optional [List [Parts ]] = []
63+ reasoning_in_content = None
6364 if isinstance (self .content , List ) and all (isinstance (x , dict ) for x in self .content ):
6465 is_parts = False
6566 for each in self .content :
67+ if not reasoning_in_content :
68+ reasoning_in_content = each .get ('summary' , '' )
6669 text = each .get ('text' , None )
6770 url = each .get ('url' , each .get ('image_url' , {}).get ('url' , None ))
6871 if text is None and url is None :
@@ -74,6 +77,8 @@ def __post_init__(self):
7477 else :
7578 self .content = self .content .__str__ ()
7679 elif isinstance (self .content , dict ):
80+ if not reasoning_in_content :
81+ reasoning_in_content = self .content .get ('summary' , '' )
7782 text = self .content .get ('text' , None )
7883 url = self .content .get ('url' , self .content .get ('image_url' , {}).get ('url' , None ))
7984 if text is not None or url is not None :
@@ -86,6 +91,11 @@ def __post_init__(self):
8691 self .content = None
8792 if len (parts ) > 0 :
8893 self .parts = parts
94+ if reasoning_in_content and not self .reasoning_content :
95+ if isinstance (reasoning_in_content , List ):
96+ self .reasoning_content = reasoning_in_content .__str__ ()
97+ else :
98+ self .reasoning_content = reasoning_in_content
8999
90100
91101@dataclass
0 commit comments