From 82f417abfe46e118dacc632e76cf813c32b6f57d Mon Sep 17 00:00:00 2001 From: renearaos Date: Fri, 19 Jun 2026 10:11:54 -0400 Subject: [PATCH] fix: remove content.strip from pattern 6 (preserve spaces), add logging to except --- litellm/llms/minimax/chat/transformation.py | 8 ++++++-- .../chat/test_minimax_streaming_handler.py | 15 ++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/litellm/llms/minimax/chat/transformation.py b/litellm/llms/minimax/chat/transformation.py index d2d75c3c25f..8cb899f3244 100644 --- a/litellm/llms/minimax/chat/transformation.py +++ b/litellm/llms/minimax/chat/transformation.py @@ -2,9 +2,12 @@ MiniMax OpenAI transformation config - extends OpenAI chat config for MiniMax's OpenAI-compatible API """ +import logging import re from typing import Any, List, Optional, Tuple +logger = logging.getLogger(__name__) + import litellm from litellm.llms.openai.chat.gpt_transformation import ( OpenAIGPTConfig, @@ -168,9 +171,10 @@ class MinimaxChatResponseIterator(OpenAIChatCompletionStreamingHandler): elif not self.finished_reasoning_content and content.strip(): if not self.started_reasoning_content: self.started_reasoning_content = True - delta["reasoning_content"] = content.strip() + delta["reasoning_content"] = content delta["content"] = None return super().chunk_parser(chunk) - except Exception: + except Exception as e: + logger.exception("MinimaxChatResponseIterator.chunk_parser error: %s", e) return super().chunk_parser(chunk) diff --git a/tests/test_litellm/llms/minimax/chat/test_minimax_streaming_handler.py b/tests/test_litellm/llms/minimax/chat/test_minimax_streaming_handler.py index 442316e7152..2d4768cd11c 100644 --- a/tests/test_litellm/llms/minimax/chat/test_minimax_streaming_handler.py +++ b/tests/test_litellm/llms/minimax/chat/test_minimax_streaming_handler.py @@ -223,8 +223,6 @@ class TestChunkParserPatterns: result = it.chunk_parser(chunk) delta = result.choices[0].delta assert delta.reasoning_content == "The user wants" - assert delta.content is None - assert it.started_reasoning_content is True def test_plain_content_skipped_empty_string(self): """Empty string content → skip (no reasoning flag).""" @@ -244,11 +242,11 @@ class TestChunkParserPatterns: c1 = _make_chunk({"content": "first "}) r1 = it.chunk_parser(c1) - assert r1.choices[0].delta.reasoning_content == "first" + assert r1.choices[0].delta.reasoning_content == "first " - c2 = _make_chunk({"content": "second "}) + c2 = _make_chunk({"content": " second "}) r2 = it.chunk_parser(c2) - assert r2.choices[0].delta.reasoning_content == "second" + assert r2.choices[0].delta.reasoning_content == " second " # ------------------------------------------------------------------ # Edge: finish / empty delta @@ -284,10 +282,13 @@ class TestChunkParserPatterns: # 2-4. plain reasoning chunks r1 = it.chunk_parser(_make_chunk({"content": "The "})) - assert r1.choices[0].delta.reasoning_content == "The" + assert r1.choices[0].delta.reasoning_content == "The " r2 = it.chunk_parser(_make_chunk({"content": "user wants "})) - assert r2.choices[0].delta.reasoning_content == "user wants" + assert r2.choices[0].delta.reasoning_content == "user wants " + + r3 = it.chunk_parser(_make_chunk({"content": "a greeting."})) + assert r3.choices[0].delta.reasoning_content == "a greeting." r3 = it.chunk_parser(_make_chunk({"content": "a greeting."})) assert r3.choices[0].delta.reasoning_content == "a greeting."