Commit cf2005b2 authored by chenghong_tao's avatar chenghong_tao

add 新建会话,fix 无法多轮对话

parent 785d75bc
...@@ -117,9 +117,11 @@ const scrollToBottom = async () => { ...@@ -117,9 +117,11 @@ const scrollToBottom = async () => {
} }
// 会话重置 // 会话重置
const resetChat = async () => { const resetChat = async (clearStore=true) => {
await inputMessageRef.value.handleCancel() await inputMessageRef.value.handleCancel()
taskStore.clear() if (clearStore) {
taskStore.clear()
}
} }
watch(() => props.historyMsgList, (newValue) => { watch(() => props.historyMsgList, (newValue) => {
......
...@@ -4,16 +4,31 @@ ...@@ -4,16 +4,31 @@
<!-- 图标按钮 --> <!-- 图标按钮 -->
<el-button :icon="Expand" v-if="!sideBarStatus" link @click="expandSidebar"/> <el-button :icon="Expand" v-if="!sideBarStatus" link @click="expandSidebar"/>
<el-button :icon="Fold" v-if="sideBarStatus" link @click="foldSidebar"/> <el-button :icon="Fold" v-if="sideBarStatus" link @click="foldSidebar"/>
<el-tooltip
class="box-item"
effect="dark"
content="新建会话"
placement="right"
>
<el-button :icon="Plus" link @click="refreshConversation"/>
</el-tooltip>
</div> </div>
<div class="center-info">{{appInfo?.app?.name}}</div> <div class="center-info">{{appInfo?.app?.name}}</div>
<div class="right-tool"> <div class="right-tool">
<el-button :icon="RefreshRight" @click="refreshConversation" link/> <el-tooltip
class="box-item"
effect="dark"
content="重置会话"
placement="left"
>
<el-button :icon="RefreshRight" @click="refreshConversation" link/>
</el-tooltip>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import {ref, computed} from 'vue' import {ref, computed} from 'vue'
import { Expand, Fold, RefreshRight } from '@element-plus/icons-vue' import { Expand, Fold, RefreshRight, CirclePlus, Plus, CirclePlusFilled } from '@element-plus/icons-vue'
import { useAppStore } from '../store/app' import { useAppStore } from '../store/app'
const appStore = useAppStore() const appStore = useAppStore()
...@@ -44,7 +59,7 @@ const refreshConversation = () => { ...@@ -44,7 +59,7 @@ const refreshConversation = () => {
display: flex; display: flex;
align-items: center; align-items: center;
.left-tool { .left-tool {
width: 30px; width: 80px;
font-size: 20px; font-size: 20px;
padding-left: 20px; padding-left: 20px;
.el-button{ .el-button{
......
...@@ -48,10 +48,13 @@ ...@@ -48,10 +48,13 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, onMounted, watch } from "vue"; import { ref, onMounted, watch, nextTick } from "vue";
import { Search, Delete, Edit } from "@element-plus/icons-vue"; import { Search, Delete, Edit } from "@element-plus/icons-vue";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import difyApi from "../apis/difyApi"; import difyApi from "../apis/difyApi";
import { useTaskStore } from "../store/task";
const taskStore = useTaskStore();
const props = defineProps({ const props = defineProps({
isRefreshHistoryList: { isRefreshHistoryList: {
...@@ -126,6 +129,10 @@ const getConversationMsg = async (id) => { ...@@ -126,6 +129,10 @@ const getConversationMsg = async (id) => {
conversation_id: id, conversation_id: id,
limit: 20, limit: 20,
}); });
taskStore.setConversationId(currentClickItemId.value)
taskStore.setTaskId('');
taskStore.setMessageId('');
taskStore.setWorkflowRunId('');
console.log("result:", result); console.log("result:", result);
emits("getHistoryMsg", result.data); emits("getHistoryMsg", result.data);
}; };
......
...@@ -44,7 +44,7 @@ const initAppInfo = async () => { ...@@ -44,7 +44,7 @@ const initAppInfo = async () => {
const refreshChat = ref(false) const refreshChat = ref(false)
const refreshConversation = (reset=true) => { const refreshConversation = (reset=true) => {
nextTick(() => { nextTick(() => {
chatRef.value.resetChat() chatRef.value.resetChat(reset)
console.log('refreshChat'); console.log('refreshChat');
refreshChat.value = true refreshChat.value = true
nextTick(() => { nextTick(() => {
......
...@@ -124,7 +124,7 @@ async function startSSE(query) { ...@@ -124,7 +124,7 @@ async function startSSE(query) {
inputs: {}, inputs: {},
query, query,
response_mode: "streaming", response_mode: "streaming",
conversation_id: "", conversation_id: taskStore.conversation_id,
user: chatMessageOptions.user, user: chatMessageOptions.user,
files: [], files: [],
}), }),
...@@ -152,6 +152,8 @@ const workflowContent = computed(() => { ...@@ -152,6 +152,8 @@ const workflowContent = computed(() => {
workflowList.push(parsedChunk); workflowList.push(parsedChunk);
if (parsedChunk.event === "workflow_started") { if (parsedChunk.event === "workflow_started") {
workflowStatus.value = 'loading'; workflowStatus.value = 'loading';
console.log("workflow_started", parsedChunk);
taskStore.setTaskId(parsedChunk.task_id); taskStore.setTaskId(parsedChunk.task_id);
taskStore.setConversationId(parsedChunk.conversation_id); taskStore.setConversationId(parsedChunk.conversation_id);
taskStore.setMessageId(parsedChunk.message_id); taskStore.setMessageId(parsedChunk.message_id);
...@@ -207,6 +209,11 @@ const messageContent = computed(() => { ...@@ -207,6 +209,11 @@ const messageContent = computed(() => {
}); });
const feedback = async (type) => { const feedback = async (type) => {
console.log('messageContent', messageContent.value)
if (messageContent.value === '') {
ElMessage.error("暂无内容可反馈");
return
}
const messageId = props.messageType === 'ai-history' ? props.historyMsgId : workflowContent.value[0].message_id; const messageId = props.messageType === 'ai-history' ? props.historyMsgId : workflowContent.value[0].message_id;
await difyApi.feedback(messageId, { rating: type, content: type }); await difyApi.feedback(messageId, { rating: type, content: type });
ElMessage.success("反馈成功"); ElMessage.success("反馈成功");
......
...@@ -35,7 +35,7 @@ const suggestedQuestions = ref([]) ...@@ -35,7 +35,7 @@ const suggestedQuestions = ref([])
watch(() => props.appParams, (val) => { watch(() => props.appParams, (val) => {
content.value = val.opening_statement; content.value = val.opening_statement;
suggestedQuestions.value = val.suggested_questions; suggestedQuestions.value = val.suggested_questions || [];
}, {immediate: true}); }, {immediate: true});
const emit = defineEmits(["userQuery"]); const emit = defineEmits(["userQuery"]);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
export default { export default {
mounted(el) { mounted(el) {
const adjustWidth = () => { const adjustWidth = () => {
const parentWidth = document.querySelector('#main-container').clientWidth; const parentWidth = document.querySelector('#main-container')?.clientWidth;
// console.log('parentWidth:', parentWidth); // console.log('parentWidth:', parentWidth);
if (parentWidth <= 740) { if (parentWidth <= 740) {
......
...@@ -13,8 +13,10 @@ export const useTaskStore = defineStore('task', { ...@@ -13,8 +13,10 @@ export const useTaskStore = defineStore('task', {
setTaskId (taskId) { setTaskId (taskId) {
this.taskId = taskId this.taskId = taskId
}, },
setConversationId (conversation_id) { setConversationId (id) {
this.conversation_id = conversation_id console.log('conversation_id', id)
this.conversation_id = id
}, },
setMessageId (message_id) { setMessageId (message_id) {
this.message_id = message_id this.message_id = message_id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment