From b9269beb7c629acb39caa99b4556b8db4613dafe Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Wed, 3 Dec 2025 10:05:02 +0800 Subject: [PATCH] fix: Recommended optimization assistant problems --- backend/apps/chat/curd/chat.py | 7 +- frontend/src/views/chat/QuickQuestion.vue | 13 +- frontend/src/views/chat/RecommendQuestion.vue | 13 +- .../src/views/chat/RecommendQuestionQuick.vue | 209 ++++++++++++++++++ .../src/views/chat/answer/ChartAnswer.vue | 6 + frontend/src/views/chat/index.vue | 9 +- 6 files changed, 242 insertions(+), 15 deletions(-) create mode 100644 frontend/src/views/chat/RecommendQuestionQuick.vue 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 } }