1414# limitations under the License.
1515
1616from abc import ABC , abstractmethod
17- from typing import TYPE_CHECKING , AsyncGenerator , List , NamedTuple
18-
19- if TYPE_CHECKING :
20- from collections .abc import AsyncIterator
17+ from typing import AsyncGenerator , List , NamedTuple
2118
2219from nemoguardrails .rails .llm .config import OutputRailsStreamingConfig
2320
@@ -114,7 +111,9 @@ def format_chunks(self, chunks: List[str]) -> str:
114111 ...
115112
116113 @abstractmethod
117- async def process_stream (self , streaming_handler ):
114+ async def process_stream (
115+ self , streaming_handler
116+ ) -> AsyncGenerator [ChunkBatch , None ]:
118117 """Process streaming chunks and yield chunk batches.
119118
120119 This is the main method that concrete buffer strategies must implement.
@@ -139,9 +138,10 @@ async def process_stream(self, streaming_handler):
139138 ... print(f"Processing: {context_formatted}")
140139 ... print(f"User: {user_formatted}")
141140 """
142- yield ChunkBatch ([], []) # pragma: no cover
141+ raise NotImplementedError
142+ yield
143143
144- async def __call__ (self , streaming_handler ):
144+ async def __call__ (self , streaming_handler ) -> AsyncGenerator [ ChunkBatch , None ] :
145145 """Callable interface that delegates to process_stream.
146146
147147 It delegates to the `process_stream` method and can
@@ -257,7 +257,9 @@ def from_config(cls, config: OutputRailsStreamingConfig):
257257 buffer_context_size = config .context_size , buffer_chunk_size = config .chunk_size
258258 )
259259
260- async def process_stream (self , streaming_handler ):
260+ async def process_stream (
261+ self , streaming_handler
262+ ) -> AsyncGenerator [ChunkBatch , None ]:
261263 """Process streaming chunks using rolling buffer strategy.
262264
263265 This method implements the rolling buffer logic, accumulating chunks
0 commit comments