Skip to content

Commit 9098f5b

Browse files
committed
Merge branch 'main' of https://github.com/dataease/SQLBot
2 parents e072a2b + ceff988 commit 9098f5b

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

backend/apps/chat/task/llm.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,16 @@ def check_save_chart(self, res: str) -> Dict[str, Any]:
662662
if data['type'] and data['type'] != 'error':
663663
# todo type check
664664
chart = data
665+
if chart.get('columns'):
666+
for v in chart.get('columns'):
667+
v['value'] = v.get('value').lower()
668+
if chart.get('axis'):
669+
if chart.get('axis').get('x'):
670+
chart.get('axis').get('x')['value'] = chart.get('axis').get('x').get('value').lower()
671+
if chart.get('axis').get('y'):
672+
chart.get('axis').get('y')['value'] = chart.get('axis').get('y').get('value').lower()
673+
if chart.get('axis').get('series'):
674+
chart.get('axis').get('series')['value'] = chart.get('axis').get('series').get('value').lower()
665675
elif data['type'] == 'error':
666676
message = data['reason']
667677
error = True

backend/apps/datasource/api/datasource.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from apps.db.engine import create_table, get_data_engine, insert_data
1010
from common.core.deps import SessionDep, CurrentUser, Trans
11+
from common.utils.utils import SQLBotLogUtil
1112
from ..crud.datasource import get_datasource_list, check_status, create_ds, update_ds, delete_ds, getTables, getFields, \
1213
execSql, update_table_and_fields, getTablesByDs, chooseTables, preview, updateTable, updateField, get_ds, fieldEnum
1314
from ..crud.field import get_fields_by_table_id
@@ -60,7 +61,11 @@ async def get_tables(session: SessionDep, id: int):
6061

6162
@router.post("/getTablesByConf")
6263
async def get_tables_by_conf(session: SessionDep, ds: CoreDatasource):
63-
return getTablesByDs(session, ds)
64+
try:
65+
return getTablesByDs(session, ds)
66+
except Exception as e:
67+
SQLBotLogUtil.error(f"get table failed: {e}")
68+
raise HTTPException(status_code=500, detail=f'Get table Failed: {e.args}')
6469

6570

6671
@router.post("/getFields/{id}/{table_name}")
@@ -100,7 +105,11 @@ async def edit_field(session: SessionDep, field: CoreField):
100105

101106
@router.post("/previewData/{id}")
102107
async def edit_local(session: SessionDep, current_user: CurrentUser, id: int, data: TableObj):
103-
return preview(session, current_user, id, data)
108+
try:
109+
return preview(session, current_user, id, data)
110+
except Exception as e:
111+
SQLBotLogUtil.error(f"Preview failed: {e}")
112+
raise HTTPException(status_code=500, detail=f'Preview Failed: {e.args}')
104113

105114

106115
@router.post("/fieldEnum/{id}")

backend/apps/datasource/crud/datasource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def getTables(session: SessionDep, id: int):
134134

135135

136136
def getTablesByDs(session: SessionDep, ds: CoreDatasource):
137-
check_status(session, ds, True)
137+
# check_status(session, ds, True)
138138
tables = get_tables(ds)
139139
return tables
140140

@@ -241,7 +241,7 @@ def updateField(session: SessionDep, field: CoreField):
241241

242242
def preview(session: SessionDep, current_user: CurrentUser, id: int, data: TableObj):
243243
ds = session.query(CoreDatasource).filter(CoreDatasource.id == id).first()
244-
check_status(session, ds, True)
244+
# check_status(session, ds, True)
245245

246246
if data.fields is None or len(data.fields) == 0:
247247
return {"fields": [], "data": [], "sql": ''}

0 commit comments

Comments
 (0)