From 37953337c60321d47d34df74f50f3cb1db6bcf9b Mon Sep 17 00:00:00 2001 From: StellaContrail Date: Mon, 2 Jun 2025 00:48:53 +0900 Subject: [PATCH] fix: ensure proper conversation role alternation for vLLM - added a comment --- .../nodes/question_classifier/question_classifier_node.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/core/workflow/nodes/question_classifier/question_classifier_node.py b/api/core/workflow/nodes/question_classifier/question_classifier_node.py index 87700cccc4..447bade00b 100644 --- a/api/core/workflow/nodes/question_classifier/question_classifier_node.py +++ b/api/core/workflow/nodes/question_classifier/question_classifier_node.py @@ -79,6 +79,10 @@ class QuestionClassifierNode(LLMNode): memory=memory, max_token_limit=rest_token, ) + # Some models (e.g. Gemma, Mistral) force roles alternation (user/assistant/user/assistant...). + # If both self._get_prompt_template and self._fetch_prompt_messages append a user prompt, + # two consecutive user prompts will be generated, causing model's error. + # To avoid this, set sys_query to an empty string so that only one user prompt is appended at the end. prompt_messages, stop = self._fetch_prompt_messages( prompt_template=prompt_template, sys_query="",