mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
Fix deepseek 'reasoning_content' error (#8963)
* fix(streaming_handler.py): fix deepseek reasoning content streaming Fixes https://github.com/BerriAI/litellm/issues/8939 * test(test_streaming_handler.py): add unit test to streaming handle 'is_chunk_non_empty' function ensures 'reasoning_content' is handled correctly
This commit is contained in:
parent
b9bddac776
commit
94d28d59e4
3 changed files with 106 additions and 8 deletions
|
@ -360,3 +360,34 @@ def test_o1_parallel_tool_calls(model):
|
|||
parallel_tool_calls=True,
|
||||
drop_params=True,
|
||||
)
|
||||
|
||||
|
||||
def test_openai_chat_completion_streaming_handler_reasoning_content():
|
||||
from litellm.llms.openai.chat.gpt_transformation import (
|
||||
OpenAIChatCompletionStreamingHandler,
|
||||
)
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
streaming_handler = OpenAIChatCompletionStreamingHandler(
|
||||
streaming_response=MagicMock(),
|
||||
sync_stream=True,
|
||||
)
|
||||
response = streaming_handler.chunk_parser(
|
||||
chunk={
|
||||
"id": "e89b6501-8ac2-464c-9550-7cd3daf94350",
|
||||
"object": "chat.completion.chunk",
|
||||
"created": 1741037890,
|
||||
"model": "deepseek-reasoner",
|
||||
"system_fingerprint": "fp_5417b77867_prod0225",
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
"delta": {"content": None, "reasoning_content": "."},
|
||||
"logprobs": None,
|
||||
"finish_reason": None,
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
assert response.choices[0].delta.reasoning_content == "."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue