Skip to content

Commit 60d63f2

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents ed797ea + 6a55003 commit 60d63f2

File tree

28 files changed

+223
-86
lines changed

28 files changed

+223
-86
lines changed

backend/apps/chat/curd/chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def get_chat_predict_data(session: SessionDep, chart_record_id: int):
6060
res = session.query(ChatRecord).options(load_only(ChatRecord.predict_data)).get(chart_record_id)
6161
if res:
6262
try:
63-
return orjson.loads(res.data)
63+
return orjson.loads(res.predict_data)
6464
except Exception:
6565
pass
6666
return ''

backend/apps/datasource/api/datasource.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
router = APIRouter(tags=["datasource"], prefix="/datasource")
1919
path = "/opt/sqlbot/data/excel"
2020

21+
2122
@router.get("/ws/{oid}", include_in_schema=False)
2223
async def query_by_oid(session: SessionDep, user: CurrentUser, oid: int) -> List[CoreDatasource]:
2324
if not user.isAdmin:
2425
raise Exception("no permission to execute")
2526
return get_datasource_list(session=session, user=user, oid=oid)
2627

28+
2729
@router.get("/list")
2830
async def datasource_list(session: SessionDep, user: CurrentUser):
2931
return get_datasource_list(session=session, user=user)
@@ -134,32 +136,11 @@ async def upload_excel(session: SessionDep, file: UploadFile = File(...)):
134136
with open(save_path, "wb") as f:
135137
f.write(await file.read())
136138

137-
conn = get_data_engine()
138139
sheets = []
139-
if filename.endswith(".csv"):
140-
df = pd.read_csv(save_path)
141-
tableName = f"sheet1_{hashlib.sha256(uuid.uuid4().bytes).hexdigest()[:10]}"
142-
sheets.append({"tableName": tableName, "tableComment": ""})
143-
column_len = len(df.dtypes)
144-
fields = []
145-
for i in range(column_len):
146-
# build fields
147-
fields.append({"name": df.columns[i], "type": str(df.dtypes[i]), "relType": ""})
148-
# create table
149-
create_table(conn, tableName, fields)
150-
151-
data = [
152-
{df.columns[i]: None if pd.isna(row[i]) else (int(row[i]) if "int" in str(df.dtypes[i]) else row[i])
153-
for i in range(len(row))}
154-
for row in df.values
155-
]
156-
# insert data
157-
insert_data(conn, tableName, fields, data)
158-
else:
159-
df_sheets = pd.read_excel(save_path, sheet_name=None)
160-
# build columns and data to insert db
161-
for sheet_name, df in df_sheets.items():
162-
tableName = f"{sheet_name}_{hashlib.sha256(uuid.uuid4().bytes).hexdigest()[:10]}"
140+
with get_data_engine() as conn:
141+
if filename.endswith(".csv"):
142+
df = pd.read_csv(save_path)
143+
tableName = f"sheet1_{hashlib.sha256(uuid.uuid4().bytes).hexdigest()[:10]}"
163144
sheets.append({"tableName": tableName, "tableComment": ""})
164145
column_len = len(df.dtypes)
165146
fields = []
@@ -176,7 +157,27 @@ async def upload_excel(session: SessionDep, file: UploadFile = File(...)):
176157
]
177158
# insert data
178159
insert_data(conn, tableName, fields, data)
179-
conn.close()
160+
else:
161+
df_sheets = pd.read_excel(save_path, sheet_name=None)
162+
# build columns and data to insert db
163+
for sheet_name, df in df_sheets.items():
164+
tableName = f"{sheet_name}_{hashlib.sha256(uuid.uuid4().bytes).hexdigest()[:10]}"
165+
sheets.append({"tableName": tableName, "tableComment": ""})
166+
column_len = len(df.dtypes)
167+
fields = []
168+
for i in range(column_len):
169+
# build fields
170+
fields.append({"name": df.columns[i], "type": str(df.dtypes[i]), "relType": ""})
171+
# create table
172+
create_table(conn, tableName, fields)
173+
174+
data = [
175+
{df.columns[i]: None if pd.isna(row[i]) else (int(row[i]) if "int" in str(df.dtypes[i]) else row[i])
176+
for i in range(len(row))}
177+
for row in df.values
178+
]
179+
# insert data
180+
insert_data(conn, tableName, fields, data)
180181

181182
os.remove(save_path)
182183
return {"filename": filename, "sheets": sheets}

backend/apps/system/api/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ async def update(session: SessionDep, editor: UserEditor, trans: Trans):
153153
raise Exception(f"User with id [{editor.id}] not found!")
154154
if editor.account != user_model.account:
155155
raise Exception(f"account cannot be changed!")
156-
if editor.email != user_model.email and check_email_exists(session=session, account=editor.email):
156+
if editor.email != user_model.email and check_email_exists(session=session, email=editor.email):
157157
raise Exception(trans('i18n_exist', msg = f"{trans('i18n_user.email')} [{editor.email}]"))
158158
if not check_email_format(editor.email):
159159
raise Exception(trans('i18n_format_invalid', key = f"{trans('i18n_user.email')} [{editor.email}]"))

backend/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ template:
138138
predict:
139139
system: |
140140
### 说明:
141-
你是一个数据分析师,你的任务是根据给定的数据进行数据预测,我将以json格式给你一组数据,你帮我预测之后的数据(一段可以展示趋势的数据,至少2个周期),用json格式返回,返回的格式需要与传入的数据格式保持一致。
141+
你是一个数据分析师,你的任务是根据给定的数据进行数据预测,我将以json格式给你一组数据,你帮我预测之后的数据(一段可以展示趋势的数据,至少2个周期),用json数组的格式返回,返回的格式需要与传入的数据格式保持一致。
142142
```json
143143
144144
无法预测或者不支持预测的数据请直接返回(不需要返回JSON格式):"抱歉,该数据无法进行预测。(有原因则返回无法预测的原因)"

frontend/src/components/layout/PwdForm.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ defineExpose({
8585
v-model="pwdForm.pwd"
8686
:placeholder="t('common.please_input', { msg: t('user.upgrade_pwd.old_pwd') })"
8787
type="password"
88+
clearable
8889
show-password
8990
/>
9091
</el-form-item>
@@ -94,6 +95,7 @@ defineExpose({
9495
:placeholder="t('common.please_input', { msg: t('user.upgrade_pwd.new_pwd') })"
9596
type="password"
9697
show-password
98+
clearable
9799
/>
98100
</el-form-item>
99101
<el-form-item prop="confirm_pwd" :label="t('user.upgrade_pwd.confirm_pwd')">
@@ -102,6 +104,7 @@ defineExpose({
102104
:placeholder="t('common.please_input', { msg: t('user.upgrade_pwd.confirm_pwd') })"
103105
type="password"
104106
show-password
107+
clearable
105108
/>
106109
</el-form-item>
107110
</el-form>

frontend/src/views/chat/ChatList.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ const handleConfirmPassword = () => {
264264
:placeholder="
265265
$t('datasource.please_enter') + $t('common.empty') + $t('qa.conversation_title')
266266
"
267+
clearable
267268
autocomplete="off"
268269
/>
269270
</el-form-item>

frontend/src/views/chat/component/ChartComponent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ let chartInstance: BaseChart | undefined
4848
4949
function renderChart() {
5050
chartInstance = getChartInstance(params.type, chartId.value)
51-
console.log(chartInstance)
5251
if (chartInstance) {
5352
chartInstance.init(axis.value, params.data)
5453
chartInstance.render()
5554
}
55+
console.debug(chartInstance)
5656
}
5757
5858
function destroyChart() {

frontend/src/views/chat/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@
290290
ref="inputRef"
291291
v-model="inputMessage"
292292
:disabled="isTyping"
293+
clearable
293294
class="input-area"
294295
type="textarea"
295296
:rows="1"
@@ -590,7 +591,7 @@ function getChatPredictData(recordId?: number) {
590591
chatApi.get_chart_predict_data(recordId).then((response) => {
591592
currentChat.value.records.forEach((record) => {
592593
if (record.id === recordId) {
593-
record.predict_data = response.data ?? []
594+
record.predict_data = response ?? []
594595
}
595596
})
596597
})

frontend/src/views/dashboard/common/ResourceGroupOpt.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ defineExpose({
185185
<el-input
186186
v-model="resourceForm.name"
187187
:placeholder="state.placeholder"
188+
clearable
188189
@keydown.stop
189190
@keyup.stop
190191
/>

frontend/src/views/dashboard/components/sq-tab/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,12 @@ defineExpose({
264264
:close-on-click-modal="false"
265265
center
266266
>
267-
<el-input v-model="state.textarea" maxlength="50" :placeholder="t('common.input_content')" />
267+
<el-input
268+
v-model="state.textarea"
269+
maxlength="50"
270+
clearable
271+
:placeholder="t('common.input_content')"
272+
/>
268273
<template #footer>
269274
<span class="dialog-footer">
270275
<el-button @click="state.dialogVisible = false">{{ t('common.cancel') }}</el-button>

0 commit comments

Comments
 (0)