From 9f522d1c03fc081529f043b56bf495176a006c53 Mon Sep 17 00:00:00 2001 From: ulleo Date: Mon, 26 May 2025 17:18:50 +0800 Subject: [PATCH] feat: Chat save & show --- backend/apps/chat/curd/chat.py | 6 +++--- frontend/src/views/chat/ChatBlock.vue | 3 ++- frontend/src/views/chat/index.vue | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/apps/chat/curd/chat.py b/backend/apps/chat/curd/chat.py index 930c4ff3..5f6c2658 100644 --- a/backend/apps/chat/curd/chat.py +++ b/backend/apps/chat/curd/chat.py @@ -59,7 +59,7 @@ def get_chat_with_records(session: SessionDep, chart_id: int, current_user: Curr chat_info.datasource_name = ds.name record_list = session.query(ChatRecord).filter( - and_(Chat.create_by == current_user.id, ChatRecord.id == chart_id)).order_by(ChatRecord.create_time).all() + and_(Chat.create_by == current_user.id, ChatRecord.chat_id == chart_id)).order_by(ChatRecord.create_time).all() chat_info.records = record_list @@ -128,7 +128,7 @@ def save_question(session: SessionDep, current_user: CurrentUser, question: Chat def save_full_question(session: SessionDep, id: int, full_question: str) -> ChatRecord: if not id: raise Exception("Record id cannot be None") - record = session.query(ChatRecord).filter(Chat.id == id).first() + record = session.query(ChatRecord).filter(ChatRecord.id == id).first() record.full_question = full_question result = ChatRecord(**record.model_dump()) @@ -146,7 +146,7 @@ def save_answer(session: SessionDep, id: int, answer: str) -> ChatRecord: if not id: raise Exception("Record id cannot be None") - record = session.query(ChatRecord).filter(Chat.id == id).first() + record = session.query(ChatRecord).filter(ChatRecord.id == id).first() record.answer = answer result = ChatRecord(**record.model_dump()) diff --git a/frontend/src/views/chat/ChatBlock.vue b/frontend/src/views/chat/ChatBlock.vue index c1a29948..32d88ea6 100644 --- a/frontend/src/views/chat/ChatBlock.vue +++ b/frontend/src/views/chat/ChatBlock.vue @@ -11,7 +11,7 @@ defineProps<{ @@ -22,5 +22,6 @@ defineProps<{ background-color: white; padding: 12px; word-wrap: break-word; + white-space: pre-wrap; } \ No newline at end of file diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue index 856f3453..db5f0de8 100644 --- a/frontend/src/views/chat/index.vue +++ b/frontend/src/views/chat/index.vue @@ -32,6 +32,7 @@
- +