H
Kevin Hu
commited on
Commit
·
503e1a6
1
Parent(s):
6cdee07
Fix Text2SQL (#2131)
Browse files### 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 <[email protected]>
- agent/canvas.py +1 -1
- agent/component/exesql.py +1 -1
- agent/templates/DB Assistant.json +2 -2
agent/canvas.py
CHANGED
@@ -260,7 +260,7 @@ class Canvas(ABC):
|
|
260 |
|
261 |
def get_history(self, window_size):
|
262 |
convs = []
|
263 |
-
for role, obj in self.history[window_size * -
|
264 |
convs.append({"role": role, "content": (obj if role == "user" else
|
265 |
'\n'.join(pd.DataFrame(obj)['content']))})
|
266 |
return convs
|
|
|
260 |
|
261 |
def get_history(self, window_size):
|
262 |
convs = []
|
263 |
+
for role, obj in self.history[(window_size + 1) * -1:]:
|
264 |
convs.append({"role": role, "content": (obj if role == "user" else
|
265 |
'\n'.join(pd.DataFrame(obj)['content']))})
|
266 |
return convs
|
agent/component/exesql.py
CHANGED
@@ -77,7 +77,7 @@ class ExeSQL(ComponentBase, ABC):
|
|
77 |
except Exception as e:
|
78 |
return ExeSQL.be_output("**Error**: \nDatabase Connection Failed! \n" + str(e))
|
79 |
sql_res = []
|
80 |
-
for single_sql in re.split(r';', ans):
|
81 |
if not single_sql:
|
82 |
continue
|
83 |
try:
|
|
|
77 |
except Exception as e:
|
78 |
return ExeSQL.be_output("**Error**: \nDatabase Connection Failed! \n" + str(e))
|
79 |
sql_res = []
|
80 |
+
for single_sql in re.split(r';', ans.replace(r"\n", " ")):
|
81 |
if not single_sql:
|
82 |
continue
|
83 |
try:
|
agent/templates/DB Assistant.json
CHANGED
@@ -63,7 +63,7 @@
|
|
63 |
}
|
64 |
],
|
65 |
"presence_penalty": 0.4,
|
66 |
-
"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.
|
67 |
"temperature": 0.1,
|
68 |
"top_p": 0.3
|
69 |
}
|
@@ -102,7 +102,7 @@
|
|
102 |
}
|
103 |
],
|
104 |
"presence_penalty": 0.4,
|
105 |
-
"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.
|
106 |
"temperature": 0.1,
|
107 |
"top_p": 0.3
|
108 |
}
|
|
|
63 |
}
|
64 |
],
|
65 |
"presence_penalty": 0.4,
|
66 |
+
"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.",
|
67 |
"temperature": 0.1,
|
68 |
"top_p": 0.3
|
69 |
}
|
|
|
102 |
}
|
103 |
],
|
104 |
"presence_penalty": 0.4,
|
105 |
+
"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.",
|
106 |
"temperature": 0.1,
|
107 |
"top_p": 0.3
|
108 |
}
|