xusenlinzy/api-for-open-llm

执行SQL chat时候报ProgrammingError错误

songyao199681 opened this issue · 2 comments

提交前必须检查以下项目 | The following items must be checked before submission

  • 请确保使用的是仓库最新代码(git pull),一些问题已被解决和修复。 | Make sure you are using the latest code from the repository (git pull), some issues have already been addressed and fixed.
  • 我已阅读项目文档FAQ章节并且已在Issue中对问题进行了搜索,没有找到相似问题和解决方案 | I have searched the existing issues / discussions

问题类型 | Type of problem

其他问题 | Other issues

操作系统 | Operating system

Linux

详细描述问题 | Detailed description of the problem

streamlit run streamlit_app.py

Dependencies

 pip list | grep -E 'transformers|peft|torch'
peft                          0.11.1
sentence-transformers         3.0.0
torch                         2.3.0
torchvision                   0.18.0
transformers                  4.41.1
transformers-stream-generator 0.0.5

运行日志或截图 | Runtime logs or screenshots

2024-06-03 17:15:48.862 Uncaught app exception
Traceback (most recent call last):
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1910, in _execute_context
    self.dialect.do_execute(
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/connections.py", line 825, in _read_query_result
    result.read()
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Question: xiaoguang年龄是多少\nSQLQuery: SELECT age FROM t2 WHERE name = 'xi' at line 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 600, in _run_script
    exec(code, module.__dict__)
  File "/software/api-for-open-llm/streamlit-demo/streamlit_app.py", line 67, in <module>
    main()
  File "/software/api-for-open-llm/streamlit-demo/streamlit_app.py", line 62, in main
    page.show()
  File "/software/api-for-open-llm/streamlit-demo/streamlit_gallery/utils/page.py", line 49, in show
    self._selected()
  File "/software/api-for-open-llm/streamlit-demo/streamlit_gallery/components/sql_chat/streamlit_app.py", line 66, in main
    sql_query, sql_result = create_sql_query(query, base_url, db_url, include_tables)
  File "/software/api-for-open-llm/streamlit-demo/streamlit_gallery/components/sql_chat/utils.py", line 44, in create_sql_query
    sql_result = db.run(sql_query, fetch="cursor")
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/langchain_community/utilities/sql_database.py", line 498, in run
    result = self._execute(
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/langchain_community/utilities/sql_database.py", line 463, in _execute
    cursor = connection.execute(
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1385, in execute
    return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/sqlalchemy/sql/elements.py", line 334, in _execute_on_connection
    return connection._execute_clauseelement(
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1577, in _execute_clauseelement
    ret = self._execute_context(
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1953, in _execute_context
    self._handle_dbapi_exception(
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2134, in _handle_dbapi_exception
    util.raise_(
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1910, in _execute_context
    self.dialect.do_execute(
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/connections.py", line 825, in _read_query_result
    result.read()
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/root/anaconda3/envs/api-for-open-llm/lib/python3.10/site-packages/pymysql/err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Question: xiaoguang年龄是多少\nSQLQuery: SELECT age FROM t2 WHERE name = 'xi' at line 1")
[SQL: Question: xiaoguang年龄是多少
SQLQuery: SELECT age FROM t2 WHERE name = 'xiaoguang']
(Background on this error at: https://sqlalche.me/e/14/f405)

gengx

gengx

什么意思,代码需要二改,我已经改好了,可以用了