File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -208,9 +208,13 @@ async def stream_response(
208208 continue
209209
210210 delta = chunk .choices [0 ].delta
211+ if hasattr (delta , "reasoning_content" ):
212+ content = delta .reasoning_content if delta .reasoning_content else delta .content
213+ else :
214+ content = delta .content
211215
212216 # Handle text
213- if delta . content :
217+ if content :
214218 if not state .text_content_index_and_output :
215219 # Initialize a content tracker for streaming text
216220 state .text_content_index_and_output = (
@@ -249,13 +253,13 @@ async def stream_response(
249253 # Emit the delta for this segment of content
250254 yield ResponseTextDeltaEvent (
251255 content_index = state .text_content_index_and_output [0 ],
252- delta = delta . content ,
256+ delta = content ,
253257 item_id = FAKE_RESPONSES_ID ,
254258 output_index = 0 ,
255259 type = "response.output_text.delta" ,
256260 )
257261 # Accumulate the text into the response part
258- state .text_content_index_and_output [1 ].text += delta . content
262+ state .text_content_index_and_output [1 ].text += content
259263
260264 # Handle refusals (model declines to answer)
261265 if delta .refusal :
You can’t perform that action at this time.
0 commit comments