@@ -450,7 +450,8 @@ def stream_complete(
450
450
451
451
return stream_complete_fn (prompt , ** kwargs )
452
452
453
- def _parse_response_output (self , output : List [ResponseOutputItem ]) -> ChatResponse :
453
+ @staticmethod
454
+ def _parse_response_output (output : List [ResponseOutputItem ]) -> ChatResponse :
454
455
message = ChatMessage (role = MessageRole .ASSISTANT , blocks = [])
455
456
additional_kwargs = {"built_in_tool_calls" : []}
456
457
tool_calls = []
@@ -526,7 +527,7 @@ def _chat(self, messages: Sequence[ChatMessage], **kwargs: Any) -> ChatResponse:
526
527
if self .track_previous_responses :
527
528
self ._previous_response_id = response .id
528
529
529
- chat_response = self ._parse_response_output (response .output )
530
+ chat_response = OpenAIResponses ._parse_response_output (response .output )
530
531
chat_response .raw = response
531
532
chat_response .additional_kwargs ["usage" ] = response .usage
532
533
if hasattr (response .usage .output_tokens_details , "reasoning_tokens" ):
@@ -590,7 +591,6 @@ def process_response_event(
590
591
elif isinstance (event , ResponseTextDeltaEvent ):
591
592
# Text content is being added
592
593
delta = event .delta
593
- blocks .append (TextBlock (text = delta ))
594
594
elif isinstance (event , ResponseImageGenCallPartialImageEvent ):
595
595
# Partial image
596
596
if event .partial_image_b64 :
@@ -653,6 +653,8 @@ def process_response_event(
653
653
# Response is complete
654
654
if hasattr (event , "response" ) and hasattr (event .response , "usage" ):
655
655
additional_kwargs ["usage" ] = event .response .usage
656
+ resp = OpenAIResponses ._parse_response_output (event .response .output )
657
+ blocks = resp .message .blocks
656
658
657
659
return (
658
660
blocks ,
@@ -782,7 +784,7 @@ async def _achat(
782
784
if self .track_previous_responses :
783
785
self ._previous_response_id = response .id
784
786
785
- chat_response = self ._parse_response_output (response .output )
787
+ chat_response = OpenAIResponses ._parse_response_output (response .output )
786
788
chat_response .raw = response
787
789
chat_response .additional_kwargs ["usage" ] = response .usage
788
790
0 commit comments