mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
feat: add query data limit in chat
This commit is contained in:
@@ -744,9 +744,14 @@ class LLMService:
|
||||
def save_sql_data(self, data_obj: Dict[str, Any]):
|
||||
try:
|
||||
data_result = data_obj.get('data')
|
||||
limit = 1000
|
||||
if data_result:
|
||||
data_result = prepare_for_orjson(data_result)
|
||||
data_obj['data'] = data_result
|
||||
if data_result and len(data_result) > limit:
|
||||
data_obj['data'] = data_result[:limit]
|
||||
data_obj['limit'] = limit
|
||||
else:
|
||||
data_obj['data'] = data_result
|
||||
return save_sql_exec_data(session=self.session, record_id=self.record.id,
|
||||
data=orjson.dumps(data_obj).decode())
|
||||
except Exception as e:
|
||||
|
||||
@@ -541,6 +541,7 @@
|
||||
"thinking": "Thinking",
|
||||
"data_analysis": "Data Analysis",
|
||||
"data_predict": "Data Prediction",
|
||||
"data_over_limit": "The data is too large, only the first {0} entries are displayed.",
|
||||
"ds_is_invalid": "Datasource is invalid",
|
||||
"error": "Error",
|
||||
"no_data": "No Data",
|
||||
@@ -602,4 +603,4 @@
|
||||
"setting_successfully": "Setting Successfully",
|
||||
"customize_theme_color": "Customize theme color"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,6 +541,7 @@
|
||||
"thinking": "思考中",
|
||||
"data_analysis": "数据分析",
|
||||
"data_predict": "数据预测",
|
||||
"data_over_limit": "数据量过大,仅展示前{0}条数据",
|
||||
"ds_is_invalid": "数据源无效",
|
||||
"error": "错误",
|
||||
"no_data": "暂无数据",
|
||||
@@ -602,4 +603,4 @@
|
||||
"setting_successfully": "设置成功",
|
||||
"customize_theme_color": "自定义主题色"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ const emits = defineEmits(['exitFullScreen'])
|
||||
const dataObject = computed<{
|
||||
fields: Array<string>
|
||||
data: Array<{ [key: string]: any }>
|
||||
limit: number | undefined
|
||||
}>(() => {
|
||||
if (props.message?.record?.data) {
|
||||
if (typeof props.message?.record?.data === 'string') {
|
||||
@@ -423,15 +424,20 @@ watch(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="message?.record?.chart" class="chart-block">
|
||||
<DisplayChartBlock
|
||||
:id="chartId"
|
||||
ref="chartRef"
|
||||
:chart-type="chartType"
|
||||
:message="message"
|
||||
:data="data"
|
||||
/>
|
||||
</div>
|
||||
<template v-if="message?.record?.chart">
|
||||
<div class="chart-block">
|
||||
<DisplayChartBlock
|
||||
:id="chartId"
|
||||
ref="chartRef"
|
||||
:chart-type="chartType"
|
||||
:message="message"
|
||||
:data="data"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="dataObject.limit" class="over-limit-hint">
|
||||
{{ t('chat.data_over_limit', [dataObject.limit]) }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<AddViewDashboard ref="addViewRef"></AddViewDashboard>
|
||||
<el-dialog
|
||||
@@ -712,6 +718,11 @@ watch(
|
||||
|
||||
margin-top: 16px;
|
||||
}
|
||||
.over-limit-hint {
|
||||
min-height: 24px;
|
||||
line-height: 24px;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.sql-block {
|
||||
|
||||
Reference in New Issue
Block a user