@@ -149,12 +149,13 @@ async def _async_chat_streamly(self, history, gen_conf, **kwargs):
149149 continue
150150 if not resp .choices [0 ].delta .content :
151151 resp .choices [0 ].delta .content = ""
152- if kwargs .get ("with_reasoning" , True ) and hasattr (resp .choices [0 ].delta , "reasoning_content" ) and resp .choices [0 ].delta .reasoning_content :
152+ _reasoning = getattr (resp .choices [0 ].delta , "reasoning_content" , None ) or getattr (resp .choices [0 ].delta , "reasoning" , None )
153+ if kwargs .get ("with_reasoning" , True ) and _reasoning :
153154 ans = ""
154155 if not reasoning_start :
155156 reasoning_start = True
156157 ans = "<think>"
157- ans += resp . choices [ 0 ]. delta . reasoning_content + "</think>"
158+ ans += _reasoning + "</think>"
158159 else :
159160 reasoning_start = False
160161 ans = resp .choices [0 ].delta .content
@@ -294,8 +295,9 @@ async def async_chat_with_tools(self, system: str, history: list, gen_conf: dict
294295 raise Exception (f"500 response structure error. Response: { response } " )
295296
296297 if not hasattr (response .choices [0 ].message , "tool_calls" ) or not response .choices [0 ].message .tool_calls :
297- if hasattr (response .choices [0 ].message , "reasoning_content" ) and response .choices [0 ].message .reasoning_content :
298- ans += "<think>" + response .choices [0 ].message .reasoning_content + "</think>"
298+ _reasoning = getattr (response .choices [0 ].message , "reasoning_content" , None ) or getattr (response .choices [0 ].message , "reasoning" , None )
299+ if _reasoning :
300+ ans += "<think>" + _reasoning + "</think>"
299301
300302 ans += response .choices [0 ].message .content
301303 if response .choices [0 ].finish_reason == "length" :
@@ -370,12 +372,13 @@ async def async_chat_streamly_with_tools(self, system: str, history: list, gen_c
370372 if not hasattr (delta , "content" ) or delta .content is None :
371373 delta .content = ""
372374
373- if hasattr (delta , "reasoning_content" ) and delta .reasoning_content :
375+ _reasoning = getattr (delta , "reasoning_content" , None ) or getattr (delta , "reasoning" , None )
376+ if _reasoning :
374377 ans = ""
375378 if not reasoning_start :
376379 reasoning_start = True
377380 ans = "<think>"
378- ans += delta . reasoning_content + "</think>"
381+ ans += _reasoning + "</think>"
379382 yield ans
380383 else :
381384 reasoning_start = False
@@ -1279,12 +1282,13 @@ async def async_chat_streamly(self, system, history, gen_conf, **kwargs):
12791282 if not hasattr (delta , "content" ) or delta .content is None :
12801283 delta .content = ""
12811284
1282- if kwargs .get ("with_reasoning" , True ) and hasattr (delta , "reasoning_content" ) and delta .reasoning_content :
1285+ _reasoning = getattr (delta , "reasoning_content" , None ) or getattr (delta , "reasoning" , None )
1286+ if kwargs .get ("with_reasoning" , True ) and _reasoning :
12831287 ans = ""
12841288 if not reasoning_start :
12851289 reasoning_start = True
12861290 ans = "<think>"
1287- ans += delta . reasoning_content + "</think>"
1291+ ans += _reasoning + "</think>"
12881292 else :
12891293 reasoning_start = False
12901294 ans = delta .content
@@ -1404,8 +1408,9 @@ async def async_chat_with_tools(self, system: str, history: list, gen_conf: dict
14041408 message = response .choices [0 ].message
14051409
14061410 if not hasattr (message , "tool_calls" ) or not message .tool_calls :
1407- if hasattr (message , "reasoning_content" ) and message .reasoning_content :
1408- ans += f"<think>{ message .reasoning_content } </think>"
1411+ _reasoning = getattr (message , "reasoning_content" , None ) or getattr (message , "reasoning" , None )
1412+ if _reasoning :
1413+ ans += f"<think>{ _reasoning } </think>"
14091414 ans += message .content or ""
14101415 if response .choices [0 ].finish_reason == "length" :
14111416 ans = self ._length_stop (ans )
@@ -1485,12 +1490,13 @@ async def async_chat_streamly_with_tools(self, system: str, history: list, gen_c
14851490 if not hasattr (delta , "content" ) or delta .content is None :
14861491 delta .content = ""
14871492
1488- if hasattr (delta , "reasoning_content" ) and delta .reasoning_content :
1493+ _reasoning = getattr (delta , "reasoning_content" , None ) or getattr (delta , "reasoning" , None )
1494+ if _reasoning :
14891495 ans = ""
14901496 if not reasoning_start :
14911497 reasoning_start = True
14921498 ans = "<think>"
1493- ans += delta . reasoning_content + "</think>"
1499+ ans += _reasoning + "</think>"
14941500 yield ans
14951501 else :
14961502 reasoning_start = False
0 commit comments