@@ -575,12 +575,13 @@ def _ensure_output_processor(self) -> None:
575575 # Already initialized, no need to reinitialize
576576 return
577577
578- # this is a hotfix - we shortcut before selecting the output pipeline for FIM
579- # because our FIM output pipeline is actually empty as of now. We should fix this
580- # but don't have any immediate need.
581- is_fim = self .proxy .context_tracking .metadata .get ("is_fim" , False )
582- if is_fim :
583- return
578+ # # this is a hotfix - we shortcut before selecting the output pipeline for FIM
579+ # # because our FIM output pipeline is actually empty as of now. We should fix this
580+ # # but don't have any immediate need.
581+ # is_fim = self.proxy.context_tracking.metadata.get("is_fim", False)
582+ # if is_fim:
583+ # return
584+ #
584585
585586 logger .debug ("Tracking context for pipeline processing" )
586587 self .sse_processor = SSEProcessor ()
@@ -601,16 +602,23 @@ async def _process_stream(self):
601602 async def stream_iterator ():
602603 while True :
603604 incoming_record = await self .stream_queue .get ()
605+
604606 record_content = incoming_record .get ("content" , {})
605607
606608 streaming_choices = []
607609 for choice in record_content .get ("choices" , []):
610+ is_fim = self .proxy .context_tracking .metadata .get ("is_fim" , False )
611+ if is_fim :
612+ content = choice .get ("text" , "" )
613+ else :
614+ content = choice .get ("delta" , {}).get ("content" )
615+
608616 streaming_choices .append (
609617 StreamingChoices (
610618 finish_reason = choice .get ("finish_reason" , None ),
611619 index = 0 ,
612620 delta = Delta (
613- content = choice . get ( "delta" , {}). get ( " content" ) , role = "assistant"
621+ content = content , role = "assistant"
614622 ),
615623 logprobs = None ,
616624 )
0 commit comments