44import itertools
55import json
66import warnings
7- from collections .abc import AsyncIterable , AsyncIterator , Generator , Iterable , Sequence
7+ from collections .abc import AsyncIterable , AsyncIterator , Iterable , Sequence
88from contextlib import asynccontextmanager
99from dataclasses import dataclass , field , replace
1010from datetime import datetime
@@ -611,7 +611,7 @@ def _process_response(self, response: chat.ChatCompletion | str) -> ModelRespons
611611 finish_reason = self ._map_finish_reason (choice .finish_reason ),
612612 )
613613
614- def _process_thinking (self , message : chat .ChatCompletionMessage ) -> Generator [ThinkingPart ]:
614+ def _process_thinking (self , message : chat .ChatCompletionMessage ) -> Iterable [ThinkingPart ]:
615615 """Hook that maps reasoning tokens to thinking parts.
616616
617617 This method may be overridden by subclasses of `OpenAIChatModel` to apply custom mappings.
@@ -627,7 +627,7 @@ def _process_thinking(self, message: chat.ChatCompletionMessage) -> Generator[Th
627627 if reasoning := getattr (message , 'reasoning' , None ):
628628 yield ThinkingPart (id = 'reasoning' , content = reasoning , provider_name = self .system )
629629
630- def _process_content (self , message : chat .ChatCompletionMessage ) -> Generator [TextPart | ThinkingPart ]:
630+ def _process_content (self , message : chat .ChatCompletionMessage ) -> Iterable [TextPart | ThinkingPart ]:
631631 """Hook that maps the message content to thinking or text parts.
632632
633633 This method may be overridden by subclasses of `OpenAIChatModel` to apply custom mappings.
@@ -636,7 +636,7 @@ def _process_content(self, message: chat.ChatCompletionMessage) -> Generator[Tex
636636 for part in split_content_into_text_and_thinking (message .content , self .profile .thinking_tags ):
637637 yield replace (part , id = 'content' , provider_name = self .system ) if isinstance (part , ThinkingPart ) else part
638638
639- def _process_tool_calls (self , message : chat .ChatCompletionMessage ) -> Generator [ToolCallPart ]:
639+ def _process_tool_calls (self , message : chat .ChatCompletionMessage ) -> Iterable [ToolCallPart ]:
640640 """Hook that maps tool calls to tool call parts.
641641
642642 This method may be overridden by subclasses of `OpenAIChatModel` to apply custom mappings.
0 commit comments