Skip to content

Commit d344e5a

Browse files
perf: Optimize DataEase integration with Advanced Assistant
1 parent e626d13 commit d344e5a

File tree

6 files changed

+30
-10
lines changed

6 files changed

+30
-10
lines changed

backend/apps/system/api/assistant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ async def ds(session: SessionDep, current_assistant: CurrentAssistant):
195195
out_ds_instance: AssistantOutDs = AssistantOutDsFactory.get_instance(current_assistant)
196196
return [
197197
{
198-
"id": ds.id,
198+
"id": str(ds.id),
199199
"name": ds.name,
200200
"description": ds.description or ds.comment,
201201
"type": ds.type,

backend/apps/system/crud/assistant.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,13 @@ def convert2schema(self, ds_dict: dict, config: dict[any]) -> AssistantOutDsSche
240240
except Exception as e:
241241
raise Exception(
242242
f"Failed to encrypt {attr} for datasource {ds_dict.get('name')}, error: {str(e)}")
243-
for attr in attr_list:
244-
if attr in ds_dict:
245-
id_marker += str(ds_dict.get(attr, '')) + '--sqlbot--'
246-
id = string_to_numeric_hash(id_marker)
243+
244+
id = ds_dict.get('id', None)
245+
if not id:
246+
for attr in attr_list:
247+
if attr in ds_dict:
248+
id_marker += str(ds_dict.get(attr, '')) + '--sqlbot--'
249+
id = string_to_numeric_hash(id_marker)
247250
db_schema = ds_dict.get('schema', ds_dict.get('db_schema', ''))
248251
ds_dict.pop("schema", None)
249252
return AssistantOutDsSchema(**{**ds_dict, "id": id, "db_schema": db_schema})

frontend/src/utils/request.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ class HttpService {
107107
!!(assistantStore.getType % 2) &&
108108
assistantStore.getCertificate
109109
) {
110-
if (config.method?.toLowerCase() === 'get' && /\/chat\/\d+$/.test(config.url || '')) {
110+
if (
111+
(config.method?.toLowerCase() === 'get' && /\/chat\/\d+$/.test(config.url || '')) ||
112+
config.url?.includes('/system/assistant/ds')
113+
) {
111114
await assistantStore.refreshCertificate()
112115
}
113116
config.headers['X-SQLBOT-ASSISTANT-CERTIFICATE'] = btoa(

frontend/src/views/chat/ChatCreator.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts" setup>
2-
import { onMounted, ref, computed, shallowRef } from 'vue'
2+
import { onMounted, ref, computed, shallowRef, onBeforeUnmount, onBeforeMount } from 'vue'
33
import icon_close_outlined from '@/assets/svg/operate/ope-close.svg'
44
import icon_add_outlined from '@/assets/svg/icon_add_outlined.svg'
55
import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
@@ -123,12 +123,26 @@ function createChat(datasource: number) {
123123
})
124124
}
125125
126+
const drawerHeight = ref(0)
127+
const setHeight = () => {
128+
drawerHeight.value = document.body.clientHeight - 100
129+
console.log(drawerHeight.value)
130+
}
131+
126132
onMounted(() => {
127133
if (props.hidden) {
128134
return
129135
}
130136
})
131137
138+
onBeforeMount(() => {
139+
setHeight()
140+
window.addEventListener('resize', setHeight)
141+
})
142+
onBeforeUnmount(() => {
143+
window.removeEventListener('resize', setHeight)
144+
})
145+
132146
const handleAddDatasource = () => {
133147
addDrawerRef.value.handleAddDatasource()
134148
}
@@ -145,7 +159,7 @@ defineExpose({
145159
<el-drawer
146160
v-model="datasourceConfigVisible"
147161
:close-on-click-modal="false"
148-
size="calc(100% - 100px)"
162+
:size="drawerHeight"
149163
modal-class="datasource-drawer-chat"
150164
direction="btt"
151165
:before-close="beforeClose"

frontend/src/views/chat/preview.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ onMounted(() => {
5757
background: #f7f8fa;
5858
box-sizing: border-box;
5959
overflow: auto;
60-
padding-bottom: 48px;
60+
// padding-bottom: 48px;
6161
}
6262
</style>

frontend/src/views/embedded/page.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,6 @@ onBeforeUnmount(() => {
235235
background: #f7f8fa;
236236
box-sizing: border-box;
237237
overflow: auto;
238-
padding-bottom: 48px;
238+
//padding-bottom: 48px;
239239
}
240240
</style>

0 commit comments

Comments
 (0)