[PR #26851] feat(stream): added a small tool to clean up LLM stream output #31588

Closed
opened 2026-02-21 20:49:45 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/26851

State: closed
Merged: No


Hey there 👋

I added a small Python class called StreamingHTMLStripper that cleans up streamed LLM responses by removing extra tags like

<details><summary>Thinking...</summary>

. It works even when those tags are split across chunks in the stream.

This helps keep the output clean and readable while the stream is still going. I also added a quick demo script and a few tests to make sure it works as expected.

How to test:

  • Run python tools/stream_filter_demo.py to see how it behaves
  • Or run pytest tests/test_stream_filter.py to check the tests

Happy to adjust anything if needed 🙂

**Original Pull Request:** https://github.com/langgenius/dify/pull/26851 **State:** closed **Merged:** No --- Hey there 👋 I added a small Python class called `StreamingHTMLStripper` that cleans up streamed LLM responses by removing extra tags like ```html <details><summary>Thinking...</summary> ``` . It works even when those tags are split across chunks in the stream. This helps keep the output clean and readable while the stream is still going. I also added a quick demo script and a few tests to make sure it works as expected. How to test: - Run `python tools/stream_filter_demo.py` to see how it behaves - Or run `pytest tests/test_stream_filter.py` to check the tests Happy to adjust anything if needed 🙂
yindo added the pull-request label 2026-02-21 20:49:45 -05:00
yindo closed this issue 2026-02-21 20:49:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31588