Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tensorrt_llm/serve/tool_parser/deepseekv3_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def parse_streaming_increment(self, new_text: str, tools: List[Tool]) -> Streami
return StreamingParseResult()
normal_text = current_text
self._buffer = ""
for e_token in [self.eot_token, "```", "<|tool▁call▁end|>"]:
for e_token in [self.eot_token, "<|tool▁call▁end|>"]:
normal_text = normal_text.replace(e_token, "")
return StreamingParseResult(normal_text=normal_text)

Expand Down
16 changes: 16 additions & 0 deletions tests/unittest/llmapi/apps/test_tool_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,22 @@ def test_deepseek_streaming_preserves_withheld_text(
sample_tools).normal_text == expected


@pytest.mark.parametrize(
"parser_cls",
[DeepSeekV3Parser, DeepSeekV31Parser, DeepSeekV32Parser, DeepSeekV4Parser])
def test_deepseek_streaming_keeps_markdown_fences(
sample_tools: list[ChatCompletionToolsParam],
parser_cls: type[BaseToolParser]) -> None:
"""Content without tool-call markup is streamed verbatim."""
text = "Here is the code:\n```python\nprint(1)\n```\nDone."

streamed = parser_cls().parse_streaming_increment(text,
sample_tools).normal_text

assert streamed == text, f"Expected {text!r}, got {streamed!r}"
assert parser_cls().detect_and_parse(text, sample_tools).normal_text == text


@pytest.mark.parametrize(
"parser_cls, tool_call_text",
[
Expand Down
Loading