feat: Chat save & show

This commit is contained in:
ulleo
2025-05-26 17:18:50 +08:00
parent b65004f07b
commit 9f522d1c03
3 changed files with 7 additions and 5 deletions
+3 -3
View File
@@ -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())
+2 -1
View File
@@ -11,7 +11,7 @@ defineProps<{
<template>
<div class="chat-block">
<slot>
{{ msg?.content }}
<div v-html="msg?.content"></div>
</slot>
</div>
</template>
@@ -22,5 +22,6 @@ defineProps<{
background-color: white;
padding: 12px;
word-wrap: break-word;
white-space: pre-wrap;
}
</style>
+2 -1
View File
@@ -32,6 +32,7 @@
</div>
<div class="input-wrapper">
<el-input
:disabled="isTyping"
class="input-area"
v-model="inputMessage"
type="textarea"
@@ -41,7 +42,7 @@
@keydown.enter.exact.prevent="sendMessage"
@keydown.ctrl.enter.exact.prevent="handleCtrlEnter"
/>
<el-button link type="primary" class="input-icon" @click="sendMessage">
<el-button link type="primary" class="input-icon" @click="sendMessage" :disabled="isTyping">
<el-icon size="20">
<Position/>
</el-icon>