[dataset] add openthought (#6866)

Former-commit-id: 20c748a4f108c0087f0d85377a4aa99126a0beb0
This commit is contained in:
hoshi-hiyouga
2025-02-09 00:53:01 +08:00
committed by GitHub
parent 4d1791e905
commit 94726bdc8d
4 changed files with 10 additions and 5 deletions

View File

@@ -36,17 +36,17 @@ if is_gradio_available():
import gradio as gr
def _format_response(text: str, lang: str) -> str:
def _format_response(text: str, lang: str, thought_words: Tuple[str, str] = ("<think>", "</think>")) -> str:
r"""
Post-processes the response text.
Based on: https://huggingface.co/spaces/Lyte/DeepSeek-R1-Distill-Qwen-1.5B-Demo-GGUF/blob/main/app.py
"""
if "<think>" not in text:
if thought_words[0] not in text:
return text
text = text.replace("<think>", "")
result = text.split("</think>", maxsplit=1)
text = text.replace(thought_words[0], "")
result = text.split(thought_words[1], maxsplit=1)
if len(result) == 1:
summary = ALERTS["info_thinking"][lang]
thought, answer = text, ""
@@ -209,7 +209,7 @@ class WebChatModel(ChatModel):
bot_text = "```json\n" + tool_calls + "\n```"
else:
output_messages = messages + [{"role": Role.ASSISTANT.value, "content": result}]
bot_text = _format_response(result, lang)
bot_text = _format_response(result, lang, self.engine.template.thought_words)
chatbot[-1] = {"role": "assistant", "content": bot_text}
yield chatbot, output_messages