Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions frontend/src/views/chat/answer/ChartAnswer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const emits = defineEmits([
'finish',
'error',
'stop',
'scrollBottom',
'update:loading',
'update:chatList',
'update:currentChat',
Expand Down Expand Up @@ -215,13 +216,18 @@ const sendMessage = async () => {
}

function getChatData(recordId?: number) {
chatApi.get_chart_data(recordId).then((response) => {
_currentChat.value.records.forEach((record) => {
if (record.id === recordId) {
record.data = response
}
chatApi
.get_chart_data(recordId)
.then((response) => {
_currentChat.value.records.forEach((record) => {
if (record.id === recordId) {
record.data = response
}
})
})
.finally(() => {
emits('scrollBottom')
})
})
}
function stop() {
stopFlag.value = true
Expand Down
20 changes: 13 additions & 7 deletions frontend/src/views/chat/answer/PredictAnswer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const props = withDefaults(
const emits = defineEmits([
'finish',
'error',
'scrollBottom',
'stop',
'update:loading',
'update:chatList',
Expand Down Expand Up @@ -215,14 +216,19 @@ function getChatPredictData(recordId?: number) {
}

function getChatData(recordId?: number) {
chatApi.get_chart_data(recordId).then((response) => {
_currentChat.value.records.forEach((record) => {
if (record.id === recordId) {
record.data = response
console.log(record.data)
}
chatApi
.get_chart_data(recordId)
.then((response) => {
_currentChat.value.records.forEach((record) => {
if (record.id === recordId) {
record.data = response
console.log(record.data)
}
})
})
.finally(() => {
emits('scrollBottom')
})
})
}

function stop() {
Expand Down
18 changes: 10 additions & 8 deletions frontend/src/views/chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
:current-chat-id="currentChatId"
:loading="isTyping"
:message="message"
@scrollBottom="scrollToBottom"
:reasoning-name="['sql_answer', 'chart_answer']"
@finish="onChartAnswerFinish"
@error="onChartAnswerError"
Expand Down Expand Up @@ -327,6 +328,7 @@
:current-chat-id="currentChatId"
:loading="isTyping"
:message="message"
@scrollBottom="scrollToBottom"
@finish="onPredictAnswerFinish"
@error="onPredictAnswerError"
@stop="onChatStop"
Expand Down Expand Up @@ -421,6 +423,8 @@ import icon_send_filled from '@/assets/svg/icon_send_filled.svg'
import { useAssistantStore } from '@/stores/assistant'
import { onClickOutside } from '@vueuse/core'
import { useUserStore } from '@/stores/user'
import { debounce } from 'lodash-es'

import router from '@/router'
const userStore = useUserStore()
const props = defineProps<{
Expand Down Expand Up @@ -454,14 +458,14 @@ const chatListRef = ref()
const innerRef = ref()
const chatCreatorRef = ref()

function scrollToBottom() {
const scrollToBottom = debounce(() => {
nextTick(() => {
chatListRef.value?.scrollTo({
top: chatListRef.value.wrapRef.scrollHeight,
behavior: 'smooth',
})
})
}
}, 300)

const loading = ref<boolean>(false)
const chatList = ref<Array<ChatInfo>>([])
Expand Down Expand Up @@ -726,12 +730,10 @@ const sendMessage = async ($event: any = {}) => {

loading.value = true
isTyping.value = true
if (isCompletePage.value) {
scrollTopVal = innerRef.value!.clientHeight
scrollTime = setInterval(() => {
scrollBottom()
}, 300)
}
scrollTopVal = innerRef.value!.clientHeight
scrollTime = setInterval(() => {
scrollBottom()
}, 300)
await assistantPrepareSend()
const currentRecord = new ChatRecord()
currentRecord.create_time = new Date()
Expand Down