mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
Merge 9ad4a5af30 into 527d882508
This commit is contained in:
commit
9de76e4ea7
2 changed files with 26 additions and 0 deletions
|
|
@ -1129,6 +1129,7 @@ class CustomStreamWrapper:
|
|||
and model_response.choices[0].delta.role is not None
|
||||
)
|
||||
or (getattr(model_response.choices[0].delta, "reasoning_items", None) is not None)
|
||||
or (getattr(model_response.choices[0].delta, "refusal", None) is not None)
|
||||
):
|
||||
return True
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -276,6 +276,31 @@ def test_is_chunk_non_empty(initialized_custom_stream_wrapper: CustomStreamWrapp
|
|||
)
|
||||
|
||||
|
||||
def test_is_chunk_non_empty_with_refusal(
|
||||
initialized_custom_stream_wrapper: CustomStreamWrapper,
|
||||
):
|
||||
"""Unit test if non-empty when the delta carries only a refusal"""
|
||||
chunk: Final = {
|
||||
"id": "chatcmpl-abc",
|
||||
"object": "chat.completion.chunk",
|
||||
"created": 1700000000,
|
||||
"model": "m",
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
"delta": {"refusal": "I can't help"},
|
||||
"logprobs": None,
|
||||
"finish_reason": None,
|
||||
}
|
||||
],
|
||||
}
|
||||
assert initialized_custom_stream_wrapper.is_chunk_non_empty(
|
||||
completion_obj=MagicMock(),
|
||||
model_response=ModelResponseStream(**chunk),
|
||||
response_obj=MagicMock(),
|
||||
)
|
||||
|
||||
|
||||
def test_is_chunk_non_empty_with_annotations(
|
||||
initialized_custom_stream_wrapper: CustomStreamWrapper,
|
||||
):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue