From 8e965040ce6bddc8ba8caa45a318d3014969dd7f Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Tue, 11 Mar 2025 10:41:19 +0800 Subject: [PATCH] Fix: rm for ES sql generation. (#5881) ### What problem does this PR solve? #5850 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/db/services/dialog_service.py | 1 + 1 file changed, 1 insertion(+) diff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.py index 8c23d1a1f..1fc190b5f 100644 --- a/api/db/services/dialog_service.py +++ b/api/db/services/dialog_service.py @@ -341,6 +341,7 @@ Please write the SQL, only SQL, without any other explanations or text. nonlocal sys_prompt, user_prompt, question, tried_times sql = chat_mdl.chat(sys_prompt, [{"role": "user", "content": user_prompt}], { "temperature": 0.06}) + sql = re.sub(r".*", "", sql, flags=re.DOTALL) logging.debug(f"{question} ==> {user_prompt} get SQL: {sql}") sql = re.sub(r"[\r\n]+", " ", sql.lower()) sql = re.sub(r".*select ", "select ", sql.lower())