@@ -199,8 +199,7 @@ async def _cleanup_after_streaming(
199199 context .sensitive .secure_cleanup ()
200200
201201 async def complete (
202- self , data : Dict , api_key : Optional [str ], is_fim_request : bool
203- ) -> Union [ModelResponse , AsyncIterator [ModelResponse ]]:
202+ self , data : Dict , api_key : Optional [str ], is_fim_request : bool ) -> Union [ModelResponse , AsyncIterator [ModelResponse ]]:
204203 """
205204 Main completion flow with pipeline integration
206205
@@ -220,20 +219,21 @@ async def complete(
220219 data .get ("base_url" ),
221220 is_fim_request ,
222221 )
223- if input_pipeline_result .response :
222+ if input_pipeline_result .response and input_pipeline_result . context :
224223 return await self ._pipeline_response_formatter .handle_pipeline_response (
225224 input_pipeline_result .response , streaming , context = input_pipeline_result .context
226225 )
227226
228- provider_request = self ._input_normalizer .denormalize (input_pipeline_result .request )
227+ if input_pipeline_result .request :
228+ provider_request = self ._input_normalizer .denormalize (input_pipeline_result .request )
229229 if is_fim_request :
230- provider_request = self ._fim_normalizer .denormalize (provider_request )
230+ provider_request = self ._fim_normalizer .denormalize (provider_request ) # type: ignore
231231
232232 # Execute the completion and translate the response
233233 # This gives us either a single response or a stream of responses
234234 # based on the streaming flag
235235 model_response = await self ._completion_handler .execute_completion (
236- provider_request , api_key = api_key , stream = streaming , is_fim_request = is_fim_request
236+ provider_request , api_key = api_key , stream = streaming , is_fim_request = is_fim_request # type: ignore
237237 )
238238 if not streaming :
239239 normalized_response = self ._output_normalizer .normalize (model_response )
@@ -242,9 +242,9 @@ async def complete(
242242 return self ._output_normalizer .denormalize (pipeline_output )
243243
244244 pipeline_output_stream = await self ._run_output_stream_pipeline (
245- input_pipeline_result .context , model_response , is_fim_request = is_fim_request
245+ input_pipeline_result .context , model_response , is_fim_request = is_fim_request # type: ignore
246246 )
247- return self ._cleanup_after_streaming (pipeline_output_stream , input_pipeline_result .context )
247+ return self ._cleanup_after_streaming (pipeline_output_stream , input_pipeline_result .context ) # type: ignore
248248
249249 def get_routes (self ) -> APIRouter :
250250 return self .router
0 commit comments