mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-04-22 14:10:01 +08:00
Fix Text2SQL (#2131)
### What problem does this PR solve? Fix exeSQL component Update DB Assistant template Fix canvas Message window size ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
parent
5daed10136
commit
b51237be17
@ -260,7 +260,7 @@ class Canvas(ABC):
|
|||||||
|
|
||||||
def get_history(self, window_size):
|
def get_history(self, window_size):
|
||||||
convs = []
|
convs = []
|
||||||
for role, obj in self.history[window_size * -2:]:
|
for role, obj in self.history[(window_size + 1) * -1:]:
|
||||||
convs.append({"role": role, "content": (obj if role == "user" else
|
convs.append({"role": role, "content": (obj if role == "user" else
|
||||||
'\n'.join(pd.DataFrame(obj)['content']))})
|
'\n'.join(pd.DataFrame(obj)['content']))})
|
||||||
return convs
|
return convs
|
||||||
|
@ -77,7 +77,7 @@ class ExeSQL(ComponentBase, ABC):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return ExeSQL.be_output("**Error**: \nDatabase Connection Failed! \n" + str(e))
|
return ExeSQL.be_output("**Error**: \nDatabase Connection Failed! \n" + str(e))
|
||||||
sql_res = []
|
sql_res = []
|
||||||
for single_sql in re.split(r';', ans):
|
for single_sql in re.split(r';', ans.replace(r"\n", " ")):
|
||||||
if not single_sql:
|
if not single_sql:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"presence_penalty": 0.4,
|
"presence_penalty": 0.4,
|
||||||
"prompt": "## You are the Repair SQL Statement Helper, please modify the original SQL statement based on the SQL query error report.\n\n## The contents of the SQL query error report and the original SQL statement are as follows:\n{exesql_input}\n\n## Answer only the modified SQL statement. Please do not give any explanation, just answer the code.",
|
"prompt": "## You are the Repair SQL Statement Helper, please modify the original SQL statement based on the SQL query error report.\n\n## The contents of the SQL query error report and the original SQL statement are as follows:\n{exesql_input}\n\n## Answer only the modified SQL statement. Each SQL statement ends with semicolon and do not give any explanation, just answer the code.",
|
||||||
"temperature": 0.1,
|
"temperature": 0.1,
|
||||||
"top_p": 0.3
|
"top_p": 0.3
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"presence_penalty": 0.4,
|
"presence_penalty": 0.4,
|
||||||
"prompt": "\n##The user provides a question and you provide SQL. You will only respond with SQL code and not with any explanations.\n\n##You may use the following DDL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {ddl_input}.\n\n##You may use the following documentation as a reference for what tables might be available. Use responses to past questions also to guide you: {db_input}.\n\n##You may use the following SQL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {sql_input}.\n\n##Respond with only SQL code. Do not answer with any explanations -- just the code.",
|
"prompt": "\n##The user provides a question and you provide SQL. You will only respond with SQL code and not with any explanations.\n\n##You may use the following DDL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {ddl_input}.\n\n##You may use the following documentation as a reference for what tables might be available. Use responses to past questions also to guide you: {db_input}.\n\n##You may use the following SQL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {sql_input}.\n\n##Respond with only SQL code. Each SQL code ends with semicolon and do not give any explanation -- just the code.",
|
||||||
"temperature": 0.1,
|
"temperature": 0.1,
|
||||||
"top_p": 0.3
|
"top_p": 0.3
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user