Skip to content

Commit 007e4a4

Browse files
committed
Update comments
Signed-off-by: declark1 <[email protected]>
1 parent a852ac4 commit 007e4a4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/orchestrator/handlers/completions_detection/streaming.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,19 +651,21 @@ async fn process_detection_batch_stream(
651651
}
652652
}
653653
}
654-
// Ensure last completion chunk with finish_reason is sent for each choice.
654+
// Ensure the last completion chunk including finish_reason is sent for each choice.
655655
//
656-
// NOTE: A known edge case where the last completion chunk would not have been included in the final batch
656+
// NOTE: A known edge case exists where the last completion chunk would not have been included in the final batch
657657
// is if it has empty choice text. This is because chunks without choice text are not sent to the detection pipeline.
658658
for (choice_index, indices) in batch_tracker {
659-
// Get last completion chunk
659+
// Lookup the last completion chunk received
660660
let completions = completion_state.completions.get(&choice_index).unwrap();
661661
let (last_index, completion) = completions
662662
.last_key_value()
663663
.map(|(index, completion)| (*index, completion))
664664
.unwrap();
665+
// Get the index of last completion chunk included in the last batch
665666
let (_start_index, end_index) = indices.last().copied().unwrap();
666667
if last_index != end_index {
668+
// The last batch didn't include the last completion chunk, send it to the response channel
667669
if last_index != end_index + 1 {
668670
warn!(%trace_id, %choice_index, %last_index, %end_index, "unexpected number of completion chunks remaining for choice");
669671
debug!(%trace_id, ?completions);

0 commit comments

Comments
 (0)