@@ -614,13 +614,13 @@ async def _stream_generator(
614614
615615 delta = chunk .choices [0 ].delta if chunk .choices else None
616616
617- # --- 1. Reasoning Content Handling ---
617+ # --- Reasoning Content Handling ---
618618 delta_reasoning = (
619619 (getattr (delta , "reasoning_content" , "" ) or "" ) if delta else ""
620620 )
621621 if delta_reasoning :
622622 full_reasoning += delta_reasoning
623- # 修复逻辑:无论是否 incremental,收到推理内容时都应输出
623+ # Output reasoning content regardless of incremental mode
624624 if is_incremental :
625625 yield self ._build_stream_response (
626626 content = "" ,
@@ -631,7 +631,7 @@ async def _stream_generator(
631631 request_id = request_id ,
632632 )
633633 else :
634- # 非增量模式下,输出当前累积的全量推理内容 + 当前累积的全量文本
634+ # In non-incremental mode, output accumulated reasoning and text
635635 yield self ._build_stream_response (
636636 content = full_text ,
637637 reasoning_content = full_reasoning ,
@@ -641,7 +641,7 @@ async def _stream_generator(
641641 request_id = request_id ,
642642 )
643643
644- # --- 2. Content Handling ---
644+ # --- Text Content Handling ---
645645 delta_content = delta .content if delta and delta .content else ""
646646 content_to_yield = ""
647647
@@ -670,7 +670,7 @@ async def _stream_generator(
670670 full_text += chunk_safe
671671 content_buffer = content_buffer [safe_chars :]
672672
673- # --- 3. Tool Calls Handling ---
673+ # --- Tool Calls Handling ---
674674 current_tool_calls_payload = None
675675 if delta and delta .tool_calls :
676676 if is_incremental :
@@ -710,9 +710,9 @@ async def _stream_generator(
710710 if upstream_finish != "null" :
711711 finish_reason = upstream_finish
712712
713- # --- 4. Yield Content Logic (Fixed) ---
713+ # --- Yield Content Logic ---
714714
715- # 判断是否有实质内容需要推送
715+ # Check if there is actual content to push
716716 has_content_update = (
717717 content_to_yield
718718 or current_tool_calls_payload
@@ -721,23 +721,22 @@ async def _stream_generator(
721721
722722 if has_content_update :
723723 if is_incremental :
724- # 增量模式:只推 delta
724+ # Incremental mode: push only delta
725725 yield self ._build_stream_response (
726726 content = content_to_yield ,
727- reasoning_content = "" , # 推理已在上方单独处理
727+ reasoning_content = "" , # Reasoning handled above
728728 tool_calls = current_tool_calls_payload ,
729729 finish_reason = (finish_reason if stop_triggered else "null" ),
730730 usage = accumulated_usage ,
731731 request_id = request_id ,
732732 )
733733 else :
734- # 非增量模式(全量模式):推送 full_text
735- # 注意:非增量模式下,Tool Calls 通常建议在结束时统一发送,或者累积发送
736- # 这里为了保持简洁,暂不实时推送未完成的 Tool Calls 结构,除非你需要
734+ # Non-incremental mode: push full text
735+ # Note: Full tool calls are usually sent at the end in non-incremental mode
737736 yield self ._build_stream_response (
738737 content = full_text ,
739738 reasoning_content = full_reasoning ,
740- tool_calls = None , # 全量模式通常不流式传输部分工具调用,只传输文本
739+ tool_calls = None ,
741740 finish_reason = (finish_reason if stop_triggered else "null" ),
742741 usage = accumulated_usage ,
743742 request_id = request_id ,
@@ -751,7 +750,7 @@ async def _stream_generator(
751750 # Flush leftover buffer if not stopped
752751 if not stop_triggered and content_buffer and stop_sequences :
753752 full_text += content_buffer
754- # 如果还有缓冲区剩余,根据模式推送
753+ # Flush remaining buffer based on mode
755754 if is_incremental :
756755 yield self ._build_stream_response (
757756 content = content_buffer ,
@@ -773,7 +772,7 @@ async def _stream_generator(
773772
774773 # Final Finish Handling
775774 if not is_incremental :
776- # 非增量模式的最后一包,包含 finish_reason 和完整的 Tool Calls
775+ # Final packet for non-incremental mode: includes finish_reason and complete Tool Calls
777776 if stop_sequences :
778777 earliest_idx , _ = self ._find_earliest_stop (full_text , stop_sequences )
779778 if earliest_idx != - 1 :
@@ -795,7 +794,7 @@ async def _stream_generator(
795794 request_id = request_id ,
796795 )
797796 else :
798- # 增量模式,如果没有通过 stop 触发结束,需要发一个空的结束包
797+ # Incremental mode: send empty end packet if not triggered by stop
799798 if not stop_triggered and finish_reason != "null" :
800799 yield self ._build_stream_response (
801800 content = "" ,
0 commit comments