Skip to content

Commit 9f522d1

Browse files
committed
feat: Chat save & show
1 parent b65004f commit 9f522d1

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

backend/apps/chat/curd/chat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def get_chat_with_records(session: SessionDep, chart_id: int, current_user: Curr
5959
chat_info.datasource_name = ds.name
6060

6161
record_list = session.query(ChatRecord).filter(
62-
and_(Chat.create_by == current_user.id, ChatRecord.id == chart_id)).order_by(ChatRecord.create_time).all()
62+
and_(Chat.create_by == current_user.id, ChatRecord.chat_id == chart_id)).order_by(ChatRecord.create_time).all()
6363

6464
chat_info.records = record_list
6565

@@ -128,7 +128,7 @@ def save_question(session: SessionDep, current_user: CurrentUser, question: Chat
128128
def save_full_question(session: SessionDep, id: int, full_question: str) -> ChatRecord:
129129
if not id:
130130
raise Exception("Record id cannot be None")
131-
record = session.query(ChatRecord).filter(Chat.id == id).first()
131+
record = session.query(ChatRecord).filter(ChatRecord.id == id).first()
132132
record.full_question = full_question
133133

134134
result = ChatRecord(**record.model_dump())
@@ -146,7 +146,7 @@ def save_answer(session: SessionDep, id: int, answer: str) -> ChatRecord:
146146
if not id:
147147
raise Exception("Record id cannot be None")
148148

149-
record = session.query(ChatRecord).filter(Chat.id == id).first()
149+
record = session.query(ChatRecord).filter(ChatRecord.id == id).first()
150150
record.answer = answer
151151

152152
result = ChatRecord(**record.model_dump())

frontend/src/views/chat/ChatBlock.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defineProps<{
1111
<template>
1212
<div class="chat-block">
1313
<slot>
14-
{{ msg?.content }}
14+
<div v-html="msg?.content"></div>
1515
</slot>
1616
</div>
1717
</template>
@@ -22,5 +22,6 @@ defineProps<{
2222
background-color: white;
2323
padding: 12px;
2424
word-wrap: break-word;
25+
white-space: pre-wrap;
2526
}
2627
</style>

frontend/src/views/chat/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
</div>
3333
<div class="input-wrapper">
3434
<el-input
35+
:disabled="isTyping"
3536
class="input-area"
3637
v-model="inputMessage"
3738
type="textarea"
@@ -41,7 +42,7 @@
4142
@keydown.enter.exact.prevent="sendMessage"
4243
@keydown.ctrl.enter.exact.prevent="handleCtrlEnter"
4344
/>
44-
<el-button link type="primary" class="input-icon" @click="sendMessage">
45+
<el-button link type="primary" class="input-icon" @click="sendMessage" :disabled="isTyping">
4546
<el-icon size="20">
4647
<Position/>
4748
</el-icon>

0 commit comments

Comments
 (0)