Skip to content

Commit a43c98e

Browse files
committed
Merge branch 'main' of https://github.com/dataease/SQLBot
2 parents f35b5af + 9f4f243 commit a43c98e

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

backend/apps/chat/task/llm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from langchain_community.utilities import SQLDatabase
1616
from langchain_core.messages import BaseMessage, SystemMessage, HumanMessage, AIMessage, BaseMessageChunk
1717
from sqlalchemy import select
18+
from sqlalchemy.exc import DBAPIError
1819
from sqlalchemy.orm import sessionmaker
1920
from sqlmodel import create_engine, Session
2021

@@ -1058,6 +1059,13 @@ def run_task(self, in_chat: bool = True):
10581059
error_msg: str
10591060
if isinstance(e, SingleMessageError):
10601061
error_msg = str(e)
1062+
elif isinstance(e, ConnectionError):
1063+
error_msg = orjson.dumps(
1064+
{'message': str(e), 'traceback': traceback.format_exc(limit=1),
1065+
'type': 'db-connection-err'}).decode()
1066+
elif isinstance(e, DBAPIError):
1067+
error_msg = orjson.dumps(
1068+
{'message': str(e), 'traceback': traceback.format_exc(limit=1), 'type': 'exec-sql-err'}).decode()
10611069
else:
10621070
error_msg = orjson.dumps({'message': str(e), 'traceback': traceback.format_exc(limit=1)}).decode()
10631071
self.save_error(message=error_msg)

frontend/src/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@
594594
"data_over_limit": "The data is too large, only the first {0} entries are displayed.",
595595
"ds_is_invalid": "Datasource is invalid",
596596
"error": "Error",
597+
"exec-sql-err": "Execute SQL failed",
597598
"no_data": "No Data",
598599
"show_error_detail": "Show error info"
599600
},

frontend/src/i18n/zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@
594594
"data_over_limit": "数据量过大,仅展示前{0}条数据",
595595
"ds_is_invalid": "数据源无效",
596596
"error": "错误",
597+
"exec-sql-err": "执行SQL失败",
597598
"no_data": "暂无数据",
598599
"show_error_detail": "查看具体信息"
599600
},

frontend/src/views/chat/ErrorInfo.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ const showBlock = computed(() => {
1717
})
1818
1919
const errorMessage = computed(() => {
20-
const obj = { message: props.error, showMore: false, traceback: '' }
20+
const obj = { message: props.error, showMore: false, traceback: '', type: '' }
2121
if (showBlock.value && props.error?.trim().startsWith('{') && props.error?.trim().endsWith('}')) {
2222
try {
2323
const json = JSON.parse(props.error?.trim())
2424
obj.message = json['message']
2525
obj.traceback = json['traceback']
26+
obj.type = json['type']
2627
if (obj.traceback?.trim().length > 0) {
2728
obj.showMore = true
2829
}
@@ -48,7 +49,15 @@ function showTraceBack() {
4849
class="error-container"
4950
></div>
5051
<div v-else class="error-container row">
51-
{{ t('chat.error') }}
52+
<template v-if="errorMessage.type === 'db-connection-err'">
53+
{{ t('chat.ds_is_invalid') }}
54+
</template>
55+
<template v-else-if="errorMessage.type === 'exec-sql-err'">
56+
{{ t('chat.exec-sql-err') }}
57+
</template>
58+
<template v-else>
59+
{{ t('chat.error') }}
60+
</template>
5261
<el-button text @click="showTraceBack">{{ t('chat.show_error_detail') }}</el-button>
5362
</div>
5463

installer/sctl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ if [ $? -ne 0 ]; then
2222
fi
2323
fi
2424

25-
if [[ ! ${SQLBOT_EXTERNAL_DB} ]] || [ "${SQLBOT_EXTERNAL_DB}" = "false" ]; then
26-
compose_files="${compose_files} -f docker-compose-pg.yml"
27-
fi
25+
#if [[ ! ${SQLBOT_EXTERNAL_DB} ]] || [ "${SQLBOT_EXTERNAL_DB}" = "false" ]; then
26+
# compose_files="${compose_files} -f docker-compose-pg.yml"
27+
#fi
2828

2929
function usage() {
3030
echo "SQLBot 控制脚本"

0 commit comments

Comments
 (0)