Whitepaper
Docs
Sign In
Function
Function
filter
DeepSeek R1 think formatter
Function ID
deepseek_r1_think_formatter
Creator
@jcarlosroldan
Downloads
1.7K+
Simple formatter that transforms <think> labels into collapsible "💭 Thought for X seconds" panels.
Get
README
No README available
Function Code
Show
""" title: DeepSeek-R1 <think> formatter author: jcarlosroldan author_url: https://github.com/jcarlosroldan Note that it only formats __after__ the full response is written. As of 2025-01-26, there's no way to format responses during completion in Open WebUI; see https://github.com/open-webui/open-webui/discussions/7223 """ from time import time class Filter: def inlet(self, body, **kwargs): self.start = time() return body async def outlet(self, body, **kwargs): body["messages"][-1]["content"] = ( body["messages"][-1]["content"] .replace( "<think>", f"<details>\n<summary>💭 Thought for {int(time() - self.start)} seconds</summary>", ) .replace("</think>", "\n\n---\n\n</details>") ) return body