-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: llama3 + NLSQLTableQueryEngine, markdown symbol on generated SQL statement #13505
Comments
The issue with markdown symbols appearing in the SQL statements generated by the Here's a quick fix you can apply: def _parse_response_to_sql(self, response: str) -> str:
# Remove common markdown symbols like *, _, and `
response = re.sub(r'[\*_`]', '', response)
# Optional: Remove everything after "SQLResult:" marker if present
sql_result_start = response.find("SQLResult:")
if sql_result_start != -1:
response = response[:sql_result_start]
return response.strip() This code snippet uses a regular expression to remove markdown symbols from the response. Adjust the regex as needed based on the symbols you encounter. Implement this modification in your local copy of the Llama3 framework, and ensure to test thoroughly to avoid introducing new issues. For further details, you might want to check the source code of the
|
Hi @dosu, NLSQLTableQueryEngine is using NLSQLRetriever. however, NLSQLRetriever doesn't have any function _parse_response_to_sql. Can you describe more detail which file or class I will need to update the code you suggested? Thank you. |
To address the issue of markdown symbols appearing in the SQL statements generated by the Here's an updated version of the def _parse_response_to_sql(self, response: str) -> str:
"""Parse response to SQL."""
# Find and remove SQLResult part
sql_result_start = response.find("SQLResult:")
if sql_result_start != -1:
response = response[:sql_result_start]
# Remove markdown symbols
response = response.replace('```', '').replace('**', '')
return response.strip() This modification strips the markdown symbols Implement this change in the
|
Question Validation
Question
Hi all,
I am facing an issue on the NLSQLTableQueryEngine, the llm I am using is Llama3.
The generated SQL sometimes contain the markdown symbol as shown below
when I try the same question several times then it works as expected and both generated SQL is the same
Can anyone give me a hint on what I miss?
Thank you.
The text was updated successfully, but these errors were encountered: