Commit cf2005b2 authored by chenghong_tao's avatar chenghong_tao

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

parent 785d75bc
......@@ -117,9 +117,11 @@ const scrollToBottom = async () => {
}
// 会话重置
const resetChat = async () => {
const resetChat = async (clearStore=true) => {
await inputMessageRef.value.handleCancel()
taskStore.clear()
if (clearStore) {
taskStore.clear()
}
}
watch(() => props.historyMsgList, (newValue) => {
......
......@@ -4,16 +4,31 @@
<!-- 图标按钮 -->
<el-button :icon="Expand" v-if="!sideBarStatus" link @click="expandSidebar"/>
<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 class="center-info">{{appInfo?.app?.name}}</div>
<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>
</template>
<script setup>
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'
const appStore = useAppStore()
......@@ -44,7 +59,7 @@ const refreshConversation = () => {
display: flex;
align-items: center;
.left-tool {
width: 30px;
width: 80px;
font-size: 20px;
padding-left: 20px;
.el-button{
......
......@@ -48,10 +48,13 @@
</div>
</template>
<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 { ElMessage, ElMessageBox } from "element-plus";
import difyApi from "../apis/difyApi";
import { useTaskStore } from "../store/task";
const taskStore = useTaskStore();
const props = defineProps({
isRefreshHistoryList: {
......@@ -126,6 +129,10 @@ const getConversationMsg = async (id) => {
conversation_id: id,
limit: 20,
});
taskStore.setConversationId(currentClickItemId.value)
taskStore.setTaskId('');
taskStore.setMessageId('');
taskStore.setWorkflowRunId('');
console.log("result:", result);
emits("getHistoryMsg", result.data);
};
......
......@@ -44,7 +44,7 @@ const initAppInfo = async () => {
const refreshChat = ref(false)
const refreshConversation = (reset=true) => {
nextTick(() => {
chatRef.value.resetChat()
chatRef.value.resetChat(reset)
console.log('refreshChat');
refreshChat.value = true
nextTick(() => {
......
......@@ -124,7 +124,7 @@ async function startSSE(query) {
inputs: {},
query,
response_mode: "streaming",
conversation_id: "",
conversation_id: taskStore.conversation_id,
user: chatMessageOptions.user,
files: [],
}),
......@@ -152,6 +152,8 @@ const workflowContent = computed(() => {
workflowList.push(parsedChunk);
if (parsedChunk.event === "workflow_started") {
workflowStatus.value = 'loading';
console.log("workflow_started", parsedChunk);
taskStore.setTaskId(parsedChunk.task_id);
taskStore.setConversationId(parsedChunk.conversation_id);
taskStore.setMessageId(parsedChunk.message_id);
......@@ -207,6 +209,11 @@ const messageContent = computed(() => {
});
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;
await difyApi.feedback(messageId, { rating: type, content: type });
ElMessage.success("反馈成功");
......
......@@ -35,7 +35,7 @@ const suggestedQuestions = ref([])
watch(() => props.appParams, (val) => {
content.value = val.opening_statement;
suggestedQuestions.value = val.suggested_questions;
suggestedQuestions.value = val.suggested_questions || [];
}, {immediate: true});
const emit = defineEmits(["userQuery"]);
......
......@@ -3,7 +3,7 @@
export default {
mounted(el) {
const adjustWidth = () => {
const parentWidth = document.querySelector('#main-container').clientWidth;
const parentWidth = document.querySelector('#main-container')?.clientWidth;
// console.log('parentWidth:', parentWidth);
if (parentWidth <= 740) {
......
......@@ -13,8 +13,10 @@ export const useTaskStore = defineStore('task', {
setTaskId (taskId) {
this.taskId = taskId
},
setConversationId (conversation_id) {
this.conversation_id = conversation_id
setConversationId (id) {
console.log('conversation_id', id)
this.conversation_id = id
},
setMessageId (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