fix: filter tetris/俄罗斯方块 from conversation history to stop hallucination

This commit is contained in:
ymq 2026-08-09 23:29:53 +08:00
parent 9b4f7dd4ae
commit b3a24a1250

View File

@ -478,9 +478,11 @@ if action == 'send_message':
for h in (await sor.sqlExe("SELECT role,content FROM pipeline_conversations WHERE created_by=${u}$ ORDER BY created_at ASC LIMIT 20",{"u":uid}) or []):
c = getattr(h,'content','') or ''
r = getattr(h,'role','') or ''
# Skip raw tool_call JSON — prevents LLM from mimicking old tool calls
# Skip raw tool_call JSON and contaminated old messages
if c.startswith('{"action":"tool_call"') or c.startswith('{"action": "tool_call"'):
continue
if 'tetris' in c.lower() or '俄罗斯方块' in c:
continue
msgs.append({"role":'user' if r=='user' else 'assistant',"content":c})
msgs.append({"role":"user","content":message_text})
await sor.C('pipeline_conversations',{'id':getID(),'role':'user','content':message_text,'msg_type':'text','org_id':org_id,'created_by':uid})