File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,7 @@ async def new_iterator_async():
286286 # type: () -> AsyncIterator[ChatCompletionChunk]
287287 with capture_internal_exceptions ():
288288 async for x in old_iterator :
289+ # OpenAI chat completion API
289290 if hasattr (x , "choices" ):
290291 choice_index = 0
291292 for choice in x .choices :
@@ -297,6 +298,11 @@ async def new_iterator_async():
297298 data_buf .append ([])
298299 data_buf [choice_index ].append (content or "" )
299300 choice_index += 1
301+ # OpenAI responses API
302+ elif hasattr (x , "delta" ):
303+ if len (data_buf ) == 0 :
304+ data_buf .append ([])
305+ data_buf [0 ].append (x .delta or "" )
300306 yield x
301307 if len (data_buf ) > 0 :
302308 all_responses = list (map (lambda chunk : "" .join (chunk ), data_buf ))
You can’t perform that action at this time.
0 commit comments