mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix: preserve non-OpenAI attributes in final streaming chunk
When an upstream server injects custom attributes into SSE streaming chunks, preserve_upstream_non_openai_attributes() correctly copies them to the ModelResponseStream for content-bearing chunks - but NOT for the final chunk (the one with finish_reason set and empty/null content). This fix adds the preserve_upstream_non_openai_attributes() call in the received_finish_reason branch, ensuring custom metadata attached to the last SSE chunk is preserved and passed to the client. Fixes #23444
This commit is contained in:
parent
176a2653da
commit
024a5de501
1 changed files with 8 additions and 0 deletions
|
|
@ -1026,6 +1026,14 @@ class CustomStreamWrapper:
|
|||
|
||||
self.sent_last_chunk = True
|
||||
|
||||
# Preserve custom attributes from original chunk to final chunk
|
||||
_original_chunk = response_obj.get("original_chunk")
|
||||
if _original_chunk:
|
||||
preserve_upstream_non_openai_attributes(
|
||||
model_response=model_response,
|
||||
original_chunk=_original_chunk,
|
||||
)
|
||||
|
||||
return model_response
|
||||
elif self._has_special_delta_content(model_response):
|
||||
return self._handle_special_delta_content(model_response)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue