diff --git a/backend/apps/chat/task/llm.py b/backend/apps/chat/task/llm.py index 39263b7d..8b92570e 100644 --- a/backend/apps/chat/task/llm.py +++ b/backend/apps/chat/task/llm.py @@ -15,6 +15,7 @@ from langchain.chat_models.base import BaseChatModel from langchain_community.utilities import SQLDatabase from langchain_core.messages import BaseMessage, SystemMessage, HumanMessage, AIMessage, BaseMessageChunk from sqlalchemy import select +from sqlalchemy.exc import DBAPIError from sqlalchemy.orm import sessionmaker from sqlmodel import create_engine, Session @@ -1058,6 +1059,13 @@ class LLMService: error_msg: str if isinstance(e, SingleMessageError): error_msg = str(e) + elif isinstance(e, ConnectionError): + error_msg = orjson.dumps( + {'message': str(e), 'traceback': traceback.format_exc(limit=1), + 'type': 'db-connection-err'}).decode() + elif isinstance(e, DBAPIError): + error_msg = orjson.dumps( + {'message': str(e), 'traceback': traceback.format_exc(limit=1), 'type': 'exec-sql-err'}).decode() else: error_msg = orjson.dumps({'message': str(e), 'traceback': traceback.format_exc(limit=1)}).decode() self.save_error(message=error_msg) diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 66a8f3b1..c0eef984 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -594,6 +594,7 @@ "data_over_limit": "The data is too large, only the first {0} entries are displayed.", "ds_is_invalid": "Datasource is invalid", "error": "Error", + "exec-sql-err": "Execute SQL failed", "no_data": "No Data", "show_error_detail": "Show error info" }, diff --git a/frontend/src/i18n/zh-CN.json b/frontend/src/i18n/zh-CN.json index a388659e..4cadc4c2 100644 --- a/frontend/src/i18n/zh-CN.json +++ b/frontend/src/i18n/zh-CN.json @@ -594,6 +594,7 @@ "data_over_limit": "数据量过大,仅展示前{0}条数据", "ds_is_invalid": "数据源无效", "error": "错误", + "exec-sql-err": "执行SQL失败", "no_data": "暂无数据", "show_error_detail": "查看具体信息" }, diff --git a/frontend/src/views/chat/ErrorInfo.vue b/frontend/src/views/chat/ErrorInfo.vue index 37bd0b4d..ce54f423 100644 --- a/frontend/src/views/chat/ErrorInfo.vue +++ b/frontend/src/views/chat/ErrorInfo.vue @@ -17,12 +17,13 @@ const showBlock = computed(() => { }) const errorMessage = computed(() => { - const obj = { message: props.error, showMore: false, traceback: '' } + const obj = { message: props.error, showMore: false, traceback: '', type: '' } if (showBlock.value && props.error?.trim().startsWith('{') && props.error?.trim().endsWith('}')) { try { const json = JSON.parse(props.error?.trim()) obj.message = json['message'] obj.traceback = json['traceback'] + obj.type = json['type'] if (obj.traceback?.trim().length > 0) { obj.showMore = true } @@ -48,7 +49,15 @@ function showTraceBack() { class="error-container" >
- {{ t('chat.error') }} + + + {{ t('chat.show_error_detail') }}
diff --git a/installer/sctl b/installer/sctl index b191ebc9..179eee17 100644 --- a/installer/sctl +++ b/installer/sctl @@ -22,9 +22,9 @@ if [ $? -ne 0 ]; then fi fi -if [[ ! ${SQLBOT_EXTERNAL_DB} ]] || [ "${SQLBOT_EXTERNAL_DB}" = "false" ]; then - compose_files="${compose_files} -f docker-compose-pg.yml" -fi +#if [[ ! ${SQLBOT_EXTERNAL_DB} ]] || [ "${SQLBOT_EXTERNAL_DB}" = "false" ]; then +# compose_files="${compose_files} -f docker-compose-pg.yml" +#fi function usage() { echo "SQLBot 控制脚本"