Feature (canvas): Add mind tagging support

-Insert the<think>tag in the message storage content to indicate the start of thinking
-Insert the</hint>tag in the message storage content to indicate the end of thinking-
This commit is contained in:
huangaoqin 2025-11-19 10:04:05 +08:00
parent bd4bc57009
commit 08251f5732

View file

@ -223,6 +223,10 @@ def completion(tenant_id, agent_id, session_id=None, **kwargs):
ans["session_id"] = session_id
if ans["event"] == "message":
txt += ans["data"]["content"]
if ans["data"].get("start_to_think", False):
txt += "<think>"
elif ans["data"].get("end_to_think", False):
txt += "</think>"
yield "data:" + json.dumps(ans, ensure_ascii=False) + "\n\n"
conv.message.append({"role": "assistant", "content": txt, "created_at": time.time(), "id": message_id})