mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-08 12:13:36 +00:00
test: fix trailing-space mismatch and add regression tests for normal models
- Fix assertion in streaming dict fallback test (trailing space in data not reflected in expected value). - Add two regression tests proving that models with reasoning_content (e.g. DeepSeek-R1) and standard models (no reasoning fields) are completely unaffected by the reasoning fallback. Made-with: Cursor
This commit is contained in:
parent
12ff8b22d6
commit
63acfc4f2f
@ -121,7 +121,7 @@ def test_parse_chunks_dict_stepfun_reasoning_fallback() -> None:
|
||||
{
|
||||
"choices": [{
|
||||
"finish_reason": None,
|
||||
"delta": {"content": None, "reasoning": "step 2. "},
|
||||
"delta": {"content": None, "reasoning": "step 2."},
|
||||
}],
|
||||
},
|
||||
{
|
||||
@ -138,6 +138,48 @@ def test_parse_chunks_dict_stepfun_reasoning_fallback() -> None:
|
||||
assert result.reasoning_content == "Thinking step 1... step 2."
|
||||
|
||||
|
||||
# ── Regression: normal models unaffected ────────────────────────────────────
|
||||
|
||||
|
||||
def test_parse_dict_normal_model_with_reasoning_content_unaffected() -> None:
|
||||
"""Models that use reasoning_content (e.g. DeepSeek-R1) are not affected."""
|
||||
with patch("nanobot.providers.openai_compat_provider.AsyncOpenAI"):
|
||||
provider = OpenAICompatProvider()
|
||||
|
||||
response = {
|
||||
"choices": [{
|
||||
"message": {
|
||||
"content": "The answer is 42.",
|
||||
"reasoning_content": "Let me think step by step...",
|
||||
},
|
||||
"finish_reason": "stop",
|
||||
}],
|
||||
}
|
||||
|
||||
result = provider._parse(response)
|
||||
|
||||
assert result.content == "The answer is 42."
|
||||
assert result.reasoning_content == "Let me think step by step..."
|
||||
|
||||
|
||||
def test_parse_dict_standard_model_no_reasoning_unaffected() -> None:
|
||||
"""Standard models (no reasoning fields at all) work exactly as before."""
|
||||
with patch("nanobot.providers.openai_compat_provider.AsyncOpenAI"):
|
||||
provider = OpenAICompatProvider()
|
||||
|
||||
response = {
|
||||
"choices": [{
|
||||
"message": {"content": "Hello!"},
|
||||
"finish_reason": "stop",
|
||||
}],
|
||||
}
|
||||
|
||||
result = provider._parse(response)
|
||||
|
||||
assert result.content == "Hello!"
|
||||
assert result.reasoning_content is None
|
||||
|
||||
|
||||
def test_parse_chunks_dict_reasoning_precedence() -> None:
|
||||
"""reasoning_content takes precedence over reasoning in dict chunks."""
|
||||
chunks = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user