mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-04-17 11:39:59 +08:00
fix Conversation roles must alternate user/assistant/user/assistant/... bug (#6880)
### What problem does this PR solve? The old logic filters out all assistant messages from messages, which, in multi-turn conversations, results in only user messages being retained. This leads to an error in locally deployed models: Conversation roles must alternate user/assistant/user/assistant/... ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [ ] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe):
This commit is contained in:
parent
08bc5d3521
commit
9d9f2dacd2
@ -240,8 +240,13 @@ def chat_completion_openai_like(tenant_id, chat_id):
|
||||
dia = dia[0]
|
||||
|
||||
# Filter system and non-sense assistant messages
|
||||
msg = None
|
||||
msg = [m for m in messages if m["role"] != "system" and (m["role"] != "assistant" or msg)]
|
||||
msg = []
|
||||
for m in messages:
|
||||
if m["role"] == "system":
|
||||
continue
|
||||
if m["role"] == "assistant" and not msg:
|
||||
continue
|
||||
msg.append(m)
|
||||
|
||||
# tools = get_tools()
|
||||
# toolcall_session = SimpleFunctionCallServer()
|
||||
|
Loading…
x
Reference in New Issue
Block a user