Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions openrag/components/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ async def stream_with_source_filtering(
if chunk_template and len(final_clean) > emitted_len:
tail_chunk = copy.deepcopy(chunk_template)
tail_chunk["choices"][0]["delta"] = {"content": final_clean[emitted_len:]}
# Content chunk must not carry finish_reason (template may be the
# finish chunk); clients treat such a chunk as terminal and drop its
# delta. The separate finish chunk below emits it with an empty delta.
tail_chunk["choices"][0]["finish_reason"] = None
tail_chunk["extra"] = filtered_json
yield f"data: {json.dumps(tail_chunk)}\n\n"

Expand Down
Loading