Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

added extra body chat template kwargs for deepseek

Alishahryar1d9c504753575
diff --git a/providers/nvidia_mixins.py b/providers/nvidia_mixins.py
index 2b8c2971..ee86fb13 100644
--- a/providers/nvidia_mixins.py
+++ b/providers/nvidia_mixins.py
@@ -96,6 +96,10 @@ class RequestBuilderMixin:
extra_body.setdefault("thinking", {"type": "enabled"})
extra_body.setdefault("reasoning_split", True)
+ # Handle DeepSeek-specific thinking mode
+ if "deepseek" in request_data.model.lower():
+ extra_body.setdefault("chat_template_kwargs", {"thinking": True})
+
body.update(extra_body)
# Apply NIM defaults
@@ -191,9 +195,7 @@ class ResponseConverterMixin:
if not reasoning:
think_content, raw_content = extract_think_content(raw_content)
if think_content:
- content.append(
- {"type": "thinking", "thinking": think_content}
- )
+ content.append({"type": "thinking", "thinking": think_content})
if raw_content:
content.append({"type": "text", "text": raw_content})
elif isinstance(raw_content, list):
diff --git a/providers/nvidia_nim.py b/providers/nvidia_nim.py
index d36acc2b..5ba40eca 100644
--- a/providers/nvidia_nim.py
+++ b/providers/nvidia_nim.py
@@ -94,6 +94,10 @@ class NvidiaNimProvider(BaseProvider):
extra_body.setdefault("thinking", {"type": "enabled"})
extra_body.setdefault("reasoning_split", True)
+ # Handle DeepSeek-specific thinking mode
+ if "deepseek" in request_data.model.lower():
+ extra_body.setdefault("chat_template_kwargs", {"thinking": True})
+
body.update(extra_body)
# Apply NIM defaults
diff --git a/tests/test_nvidia_nim.py b/tests/test_nvidia_nim.py
index b0a40d41..2f5f6a98 100644
--- a/tests/test_nvidia_nim.py
+++ b/tests/test_nvidia_nim.py
@@ -105,6 +105,25 @@ async def test_build_request_body_with_tools(nim_provider):
assert body["tools"][0]["function"]["name"] == "test_tool"
+async def test_build_request_body_deepseek(nim_provider):
+ """Test request body with DeepSeek model."""
+ req = MockRequest(model="deepseek-ai/deepseek-r1")
+ body = nim_provider._build_request_body(req)
+
+ assert "chat_template_kwargs" in body
+ assert body["chat_template_kwargs"] == {"thinking": True}
+
+
+async def test_build_request_body_non_deepseek(nim_provider):
+ """Test request body with non-DeepSeek model."""
+ req = MockRequest(model="meta/llama-3.3-70b-instruct")
+ body = nim_provider._build_request_body(req)
+
+ assert "chat_template_kwargs" not in body
+
+
@pytest.mark.asyncio
async def test_stream_response_text(nim_provider):
"""Test streaming text response."""