diff --git a/backend/apps/chat/curd/chat.py b/backend/apps/chat/curd/chat.py index f6dafb443..711c20515 100644 --- a/backend/apps/chat/curd/chat.py +++ b/backend/apps/chat/curd/chat.py @@ -42,13 +42,16 @@ def list_chats(session: SessionDep, current_user: CurrentUser) -> List[Chat]: def list_recent_questions(session: SessionDep, current_user: CurrentUser, datasource_id: int) -> List[str]: chat_records = ( - session.query(ChatRecord.question) + session.query( + ChatRecord.question, + func.count(ChatRecord.question).label('question_count') + ) .filter( ChatRecord.datasource == datasource_id, ChatRecord.question.isnot(None) ) .group_by(ChatRecord.question) - .order_by(desc(func.max(ChatRecord.create_time))) + .order_by(desc('question_count'), desc(func.max(ChatRecord.create_time))) .limit(10) .all() ) diff --git a/frontend/src/views/chat/QuickQuestion.vue b/frontend/src/views/chat/QuickQuestion.vue index fa6fe5082..dd412a59d 100644 --- a/frontend/src/views/chat/QuickQuestion.vue +++ b/frontend/src/views/chat/QuickQuestion.vue @@ -1,11 +1,11 @@ + + + + diff --git a/frontend/src/views/chat/answer/ChartAnswer.vue b/frontend/src/views/chat/answer/ChartAnswer.vue index c424585fd..14ed3a786 100644 --- a/frontend/src/views/chat/answer/ChartAnswer.vue +++ b/frontend/src/views/chat/answer/ChartAnswer.vue @@ -194,6 +194,12 @@ const sendMessage = async () => { case 'chart': _currentChat.value.records[index.value].chart = data.content break + case 'datasource': + if (!_currentChat.value.datasource) { + _currentChat.value.datasource = data.id + } + _currentChat.value.records[index.value].chart = data.content + break case 'finish': emits('finish', currentRecord.id) break diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue index faecc55d3..9c6b305f5 100644 --- a/frontend/src/views/chat/index.vue +++ b/frontend/src/views/chat/index.vue @@ -1,8 +1,8 @@ -
+
{ - quickQuestionRef.value.getRecommendQuestions() - }) + // do nothing } }