mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
Merge branch 'main' of https://github.com/dataease/SQLBot
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
@@ -594,6 +594,7 @@
|
||||
"data_over_limit": "数据量过大,仅展示前{0}条数据",
|
||||
"ds_is_invalid": "数据源无效",
|
||||
"error": "错误",
|
||||
"exec-sql-err": "执行SQL失败",
|
||||
"no_data": "暂无数据",
|
||||
"show_error_detail": "查看具体信息"
|
||||
},
|
||||
|
||||
@@ -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"
|
||||
></div>
|
||||
<div v-else class="error-container row">
|
||||
{{ t('chat.error') }}
|
||||
<template v-if="errorMessage.type === 'db-connection-err'">
|
||||
{{ t('chat.ds_is_invalid') }}
|
||||
</template>
|
||||
<template v-else-if="errorMessage.type === 'exec-sql-err'">
|
||||
{{ t('chat.exec-sql-err') }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ t('chat.error') }}
|
||||
</template>
|
||||
<el-button text @click="showTraceBack">{{ t('chat.show_error_detail') }}</el-button>
|
||||
</div>
|
||||
|
||||
|
||||
+3
-3
@@ -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 控制脚本"
|
||||
|
||||
Reference in New Issue
Block a user