File tree 1 file changed +7
-3
lines changed
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(
208
208
continue
209
209
210
210
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
211
215
212
216
# Handle text
213
- if delta . content :
217
+ if content :
214
218
if not state .text_content_index_and_output :
215
219
# Initialize a content tracker for streaming text
216
220
state .text_content_index_and_output = (
@@ -249,13 +253,13 @@ async def stream_response(
249
253
# Emit the delta for this segment of content
250
254
yield ResponseTextDeltaEvent (
251
255
content_index = state .text_content_index_and_output [0 ],
252
- delta = delta . content ,
256
+ delta = content ,
253
257
item_id = FAKE_RESPONSES_ID ,
254
258
output_index = 0 ,
255
259
type = "response.output_text.delta" ,
256
260
)
257
261
# 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
259
263
260
264
# Handle refusals (model declines to answer)
261
265
if delta .refusal :
You can’t perform that action at this time.
0 commit comments