From 53fd55bdf6544ae9c2697e460766ce2d53044dbe Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期一, 26 八月 2024 14:54:26 +0800
Subject: [PATCH] fix: 修改bug
---
src/views/sessionManager/components/smartAi.vue | 361 ++++-----
config/vite.config.dev.ts | 12
src/assets/images/icon-picture.png | 0
src/views/sessionManager/components/agentSession.vue | 1258 +++++++++++++++++----------------
src/views/sessionManager/components/chatMenu.vue | 407 +++++-----
src/views/sessionManager/index.vue | 126 +-
6 files changed, 1,110 insertions(+), 1,054 deletions(-)
diff --git a/config/vite.config.dev.ts b/config/vite.config.dev.ts
index 8238ae6..3bb9577 100644
--- a/config/vite.config.dev.ts
+++ b/config/vite.config.dev.ts
@@ -14,8 +14,8 @@
proxy: {
'/base': {
// target: 'http://aiotlink.com:8189',
- //target: 'http://192.168.20.116:8089',
- target: 'http://192.168.20.158:8089',
+ target: 'http://192.168.20.116:8089',
+ // target: 'http://192.168.20.158:8089',
changeOrigin: true,
ws: true,
// rewrite: (path) => path.replace(new RegExp(`^/basic-api`), ''),
@@ -24,16 +24,16 @@
},
'/api': {
// target: 'http://aiotlink.com:8189',
- //target: 'http://192.168.20.116:8089',
- target: 'http://192.168.20.158:8089',
+ target: 'http://192.168.20.116:8089',
+ // target: 'http://192.168.20.158:8089',
changeOrigin: true,
ws: true,
// rewrite: (path) => path.replace(new RegExp(`^/basic-api`), ''),
},
'/api/v1': {
// target: 'http://aiotlink.com:8189',
- //target: 'http://192.168.20.116:8089',
- target: 'http://192.168.20.158:8089',
+ target: 'http://192.168.20.116:8089',
+ // target: 'http://192.168.20.158:8089',
changeOrigin: true,
ws: true,
// rewrite: (path) => path.replace(new RegExp(`^/basic-api`), ''),
diff --git a/src/assets/images/icon-picture.png b/src/assets/images/icon-picture.png
new file mode 100644
index 0000000..a90c9c9
--- /dev/null
+++ b/src/assets/images/icon-picture.png
Binary files differ
diff --git a/src/views/sessionManager/components/agentSession.vue b/src/views/sessionManager/components/agentSession.vue
index 9f193ca..59f1821 100644
--- a/src/views/sessionManager/components/agentSession.vue
+++ b/src/views/sessionManager/components/agentSession.vue
@@ -3,19 +3,18 @@
<div class="header___lEPyH">
<div class="chatHeader">
<div class="chatHeaderBox">
-<!-- <span class="title">{{agentTitle}}</span>-->
- <a-popover
- position="bottom"
- trigger="click"
- >
- <a-button border
- >
- <span style="
- width: 100px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- ">{{ from.name }}</span>
+ <!-- <span class="title">{{agentTitle}}</span>-->
+ <a-popover position="bottom" trigger="click">
+ <a-button border>
+ <span
+ style="
+ width: 100px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ "
+ >{{ from.name }}</span
+ >
<icon-down style="margin-left: 4px" />
</a-button>
<template #content>
@@ -41,13 +40,13 @@
id="agentHome"
class="chat-list"
style="
- width: 80%;
- overflow: auto;
- height: calc(100vh - 380px);
- margin: 0px auto 20px;
- "
+ width: 80%;
+ overflow: auto;
+ height: calc(100vh - 380px);
+ margin: 0px auto 20px;
+ "
>
- <div class="chat-item" v-for="(sessionDetail,index) in sessionDetailList">
+ <div class="chat-item" v-for="(sessionDetail, index) in sessionDetailList">
<a-comment v-if="sessionDetail.role === 'user'">
<template #avatar>
<img
@@ -58,7 +57,7 @@
</template>
<template #content>
<div :class="{ chartUserText: theme === 'light' }"
- >{{ sessionDetail.content }}
+ >{{ sessionDetail.content }}
</div>
</template>
</a-comment>
@@ -66,33 +65,43 @@
<template #avatar>
<img
class="icon-user-jpg"
- src="../../../assets/images/icon-chart.png"
+ src="../../../assets/images/icon-picture.png"
alt="鏈湴鍥剧墖"
/>
</template>
<template #content>
-<!-- <a-card :class="{ chatItemAnswer: theme === 'light' }">-->
-<!-- <div :class="{ light: theme === 'light' }"-->
-<!-- >{{ sessionDetail.content }}-->
-<!-- </div>-->
-<!-- </a-card>-->
+ <!-- <a-card :class="{ chatItemAnswer: theme === 'light' }">-->
+ <!-- <div :class="{ light: theme === 'light' }"-->
+ <!-- >{{ sessionDetail.content }}-->
+ <!-- </div>-->
+ <!-- </a-card>-->
<a-textarea
readonly
auto-size
v-model="sessionDetail.content"
:class="{ chatItemAnswer: theme === 'light' }"
- :style="{ backgroundColor: theme === 'light' ? '#ffffff' : '#000000'}"
+ :style="{
+ backgroundColor: theme === 'light' ? '#ffffff' : '#000000',
+ }"
style="border: none"
>
</a-textarea>
</template>
<template #actions>
- <span class="action" v-if="index != 0" @click="copy(sessionDetail.content)">
- <icon-copy /> 澶嶅埗
- </span>
- <span class="action" v-if="index != 0 && index == sessionDetailList.length - 1" @click="reGenerate()">
- <icon-refresh /> 閲嶆柊鐢熸垚
- </span>
+ <span
+ class="action"
+ v-if="index != 0"
+ @click="copy(sessionDetail.content)"
+ >
+ <icon-copy /> 澶嶅埗
+ </span>
+ <span
+ class="action"
+ v-if="index != 0 && index == sessionDetailList.length - 1"
+ @click="reGenerate()"
+ >
+ <icon-refresh /> 閲嶆柊鐢熸垚
+ </span>
</template>
</a-comment>
<a-comment v-else-if="sessionDetail.role === 'last'">
@@ -109,15 +118,23 @@
auto-size
v-model="displayedText"
:class="{ chatItemAnswer: theme === 'light' }"
- :style="{backgroundColor: theme === 'light' ? '#ffffff' : '#000000'}"
+ :style="{
+ backgroundColor: theme === 'light' ? '#ffffff' : '#000000',
+ }"
style="border: none"
>
</a-textarea>
</template>
<template #actions>
- <div class="action"
- @click="stopChat"
- style="background: var(--color-bg-2);color: var(--color-primary-light-4);" v-if="displayedText != ''">
+ <div
+ class="action"
+ @click="stopChat"
+ style="
+ background: var(--color-bg-2);
+ color: var(--color-primary-light-4);
+ "
+ v-if="displayedText != ''"
+ >
<icon-record-stop />
鍋滄鐢熸垚
</div>
@@ -140,14 +157,14 @@
show-word-limit
:disabled="chatDis"
:class="{ textItemAnswer: theme === 'dark' }"
- :style="{backgroundColor: theme === 'light' ? '#ffffff' : '#000000'}"
+ :style="{ backgroundColor: theme === 'light' ? '#ffffff' : '#000000' }"
style="border: none"
:auto-size="{
- minRows: 12,
- maxRows: 5,
- }"
+ minRows: 12,
+ maxRows: 5,
+ }"
/>
- <div style="width: 100%;display: flex;justify-content: space-between">
+ <div style="width: 100%; display: flex; justify-content: space-between">
<span></span>
<a-button
:disabled="chatDis"
@@ -156,33 +173,44 @@
style="border-radius: 24px"
:loading="loading"
>
- <icon-send size="32" style="color: #0960bd;"/>
- </a-button
- >
+ <icon-send size="32" style="color: #0960bd" />
+ </a-button>
</div>
-<!-- <div class="btn-send">-->
-<!-- <!– <icon-send size="32" /> –>-->
-<!-- <a-button-->
-<!-- :disabled="chatDis"-->
-<!-- @click="sentClick"-->
-<!-- type="text"-->
-<!-- style="border-radius: 24px"-->
-<!-- :loading="loading"-->
-<!-- >-->
-<!-- <icon-send size="32" style="color: #0960bd;"/>-->
-<!-- </a-button-->
-<!-- >-->
-<!-- </div>-->
+ <!-- <div class="btn-send">-->
+ <!-- <!– <icon-send size="32" /> –>-->
+ <!-- <a-button-->
+ <!-- :disabled="chatDis"-->
+ <!-- @click="sentClick"-->
+ <!-- type="text"-->
+ <!-- style="border-radius: 24px"-->
+ <!-- :loading="loading"-->
+ <!-- >-->
+ <!-- <icon-send size="32" style="color: #0960bd;"/>-->
+ <!-- </a-button-->
+ <!-- >-->
+ <!-- </div>-->
</div>
- <a-modal v-model:visible="visible" title="淇敼鍚嶇О" @before-open="handleOpened" @cancel="handleCancel" :footer="false" title-align="start">
- <a-form ref="formRef" :rules="rules" :model="from" @submit="handleSubmit" >
+ <a-modal
+ v-model:visible="visible"
+ title="淇敼鍚嶇О"
+ @before-open="handleOpened"
+ @cancel="handleCancel"
+ :footer="false"
+ title-align="start"
+ >
+ <a-form ref="formRef" :rules="rules" :model="from" @submit="handleSubmit">
<a-form-item field="name" label="鍚嶇О">
- <a-input v-model="from.name" placeholder="璇疯緭鍏ュ悕绉�"/>
+ <a-input v-model="from.name" placeholder="璇疯緭鍏ュ悕绉�" />
</a-form-item>
<a-form-item>
- <div style="width: 100%;text-align: right">
+ <div style="width: 100%; text-align: right">
<a-button @click="visible = false">鍙栨秷</a-button>
- <a-button style="margin-left: 10px" type="primary" html-type="submit">纭畾</a-button>
+ <a-button
+ style="margin-left: 10px"
+ type="primary"
+ html-type="submit"
+ >纭畾</a-button
+ >
</div>
</a-form-item>
</a-form>
@@ -191,606 +219,610 @@
</template>
<script setup lang="ts">
-import { defineProps, ref, watch, defineEmits, onMounted, reactive, computed, nextTick, onBeforeUnmount } from "vue";
-import { Message } from '@arco-design/web-vue';
-import { useAppStore } from "@/store";
-import { getAuthorization } from "@/utils/auth";
-import { EventSourceParserStream } from 'eventsource-parser/stream';
-import { agentResetApi, agentSetApi, getAgentSessionDetailsApi } from "@/api/agentSession";
-import EventBus from '@/utils/EventBus';
-import useClipboard from "vue-clipboard3";
-import { addSessionApi, getSessionDetailsApi } from "@/api/session";
-const props = defineProps({
- modalObj: Object,
-});
-
-// const emit = defineEmits(['addSession']);
-
-const sessionDetailList = ref([]); //鏍规嵁浼氳瘽id鍑烘潵鐨勪細璇濊鎯�
-const sessionList = ref([]); //浼氳瘽鍒楄〃
-const modalObj = reactive({ });
-const dialogId = ref('');
-const chatDis = ref(false);
-const loading = ref(false);
-const agentTitle = ref("鏈懡鍚嶄細璇�");
-
-
-const currIndex = ref(0);
-const displayedText = ref(''); // 姝e湪鏄剧ず鐨勬枃瀛�
-let timer: number | null = null;
-const streamStr = ref('');
-const inputMsg = ref('');
-const activeSessionId = ref('');
-const conversation_id = ref('');
-const fieldNames = { value: 'id', label: 'name' };
-const agentObj = reactive({});
-const agentList = ref([]);
-const selectValue = ref('');
-const sectionList = ref({});
-let chatObj = reactive({});
-const isStopChat = ref(false)
-const appStore = useAppStore();
-const theme = computed(() => {
- return appStore.theme;
-});
-let from = reactive({
- name:'鏈懡鍚嶄細璇�',
-});
-
-const visible = ref(false);
-let isHistory = ref(false);//鏄惁鏄巻鍙茶褰�
-let dsl = reactive({});
-const chatDataMeg = reactive({});
-
-
-const rules = {
- name: [
- {
- required: true,
- message:'鍚嶇О涓嶅厑璁镐负绌�',
- },
- ],
-}
-
-const handleSubmit = async({values, errors}) => {
- if(errors) return;
- console.log(agentObj, 'agentObj');
- let chatData = {
- id:conversation_id.value,
- conversation_id:conversation_id.value,
- name: from.name
- }
- const { code, data } = await addSessionApi(chatData);
- if (data) {
- Message.success("淇敼鎴愬姛");
- handleCancel()
- }
-}
-
-const handleClick = () => {
- visible.value = true;
-};
-const handleCancel = () => {
- visible.value = false;
-}
-
-const handleOpened =(el) => {
- // Object.assign(form,{
- // name: '',// 鐢ㄦ埛鍚�
- // });
- // formRef.value.resetFields();
-}
-
-
-// 鍒濆鍖栭〉闈�
-const initPage = async () => {
- agentSet();
-};
-
-const createNewAgent = async (session) => {
- console.log(session,'鏂板缓agent浼氳瘽瀵硅薄');
- Object.assign(agentObj, session);
- isHistory.value = false;
- initPage();
-}
-// 璋冪敤set鏂规硶
-const agentSet = async () => {
- const res = await agentSetApi({
- id: agentObj.id,
- title: agentObj.title,
- dsl: agentObj.dsl,
+ import {
+ defineProps,
+ ref,
+ watch,
+ defineEmits,
+ onMounted,
+ reactive,
+ computed,
+ nextTick,
+ onBeforeUnmount,
+ } from 'vue';
+ import { Message } from '@arco-design/web-vue';
+ import { useAppStore } from '@/store';
+ import { getAuthorization } from '@/utils/auth';
+ import { EventSourceParserStream } from 'eventsource-parser/stream';
+ import {
+ agentResetApi,
+ agentSetApi,
+ getAgentSessionDetailsApi,
+ } from '@/api/agentSession';
+ import EventBus from '@/utils/EventBus';
+ import useClipboard from 'vue-clipboard3';
+ import { addSessionApi, getSessionDetailsApi } from '@/api/session';
+ const props = defineProps({
+ modalObj: Object,
});
- // console.log(res,'agentSet');
- if (res.code == 0) {
- conversation_id.value = res.data.conversation_id;
- agentReset();
- }
-}
-// 璋冪敤reset鏂规硶
-const agentReset = async () => {
- const res = await agentResetApi({
- id: agentObj.id,
+
+ // const emit = defineEmits(['addSession']);
+
+ const sessionDetailList = ref([]); //鏍规嵁浼氳瘽id鍑烘潵鐨勪細璇濊鎯�
+ const sessionList = ref([]); //浼氳瘽鍒楄〃
+ const modalObj = reactive({});
+ const dialogId = ref('');
+ const chatDis = ref(false);
+ const loading = ref(false);
+ const agentTitle = ref('鏈懡鍚嶄細璇�');
+
+ const currIndex = ref(0);
+ const displayedText = ref(''); // 姝e湪鏄剧ず鐨勬枃瀛�
+ let timer: number | null = null;
+ const streamStr = ref('');
+ const inputMsg = ref('');
+ const activeSessionId = ref('');
+ const conversation_id = ref('');
+ const fieldNames = { value: 'id', label: 'name' };
+ const agentObj = reactive({});
+ const agentList = ref([]);
+ const selectValue = ref('');
+ const sectionList = ref({});
+ let chatObj = reactive({});
+ const isStopChat = ref(false);
+ const appStore = useAppStore();
+ const theme = computed(() => {
+ return appStore.theme;
});
- if (res.code == 0) {
- // Message.success('淇敼鎴愬姛');
- agentCompletion();
- }
-}
-// 璋冪敤completion鏂规硶
-const agentCompletion = async () => {
- const response = await fetch(
- '/api/v1/canvas/completion',
- {
+ let from = reactive({
+ name: '鏈懡鍚嶄細璇�',
+ });
+
+ const visible = ref(false);
+ let isHistory = ref(false); //鏄惁鏄巻鍙茶褰�
+ let dsl = reactive({});
+ const chatDataMeg = reactive({});
+
+ const rules = {
+ name: [
+ {
+ required: true,
+ message: '鍚嶇О涓嶅厑璁镐负绌�',
+ },
+ ],
+ };
+
+ const handleSubmit = async ({ values, errors }) => {
+ if (errors) return;
+ console.log(agentObj, 'agentObj');
+ let chatData = {
+ id: conversation_id.value,
+ conversation_id: conversation_id.value,
+ name: from.name,
+ };
+ const { code, data } = await addSessionApi(chatData);
+ if (data) {
+ Message.success('淇敼鎴愬姛');
+ handleCancel();
+ }
+ };
+
+ const handleClick = () => {
+ visible.value = true;
+ };
+ const handleCancel = () => {
+ visible.value = false;
+ };
+
+ const handleOpened = (el) => {
+ // Object.assign(form,{
+ // name: '',// 鐢ㄦ埛鍚�
+ // });
+ // formRef.value.resetFields();
+ };
+
+ // 鍒濆鍖栭〉闈�
+ const initPage = async () => {
+ agentSet();
+ };
+
+ const createNewAgent = async (session) => {
+ console.log(session, '鏂板缓agent浼氳瘽瀵硅薄');
+ Object.assign(agentObj, session);
+ isHistory.value = false;
+ initPage();
+ };
+ // 璋冪敤set鏂规硶
+ const agentSet = async () => {
+ const res = await agentSetApi({
+ id: agentObj.id,
+ title: agentObj.title,
+ dsl: agentObj.dsl,
+ });
+ // console.log(res,'agentSet');
+ if (res.code == 0) {
+ conversation_id.value = res.data.conversation_id;
+ agentReset();
+ }
+ };
+ // 璋冪敤reset鏂规硶
+ const agentReset = async () => {
+ const res = await agentResetApi({
+ id: agentObj.id,
+ });
+ if (res.code == 0) {
+ // Message.success('淇敼鎴愬姛');
+ agentCompletion();
+ }
+ };
+ // 璋冪敤completion鏂规硶
+ const agentCompletion = async () => {
+ const response = await fetch('/api/v1/canvas/completion', {
method: 'POST',
headers: {
'Authorization': getAuthorization(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
- id: agentObj.id
+ id: agentObj.id,
}),
- }
- );
+ });
- const reader = response?.body
- ?.pipeThrough(new TextDecoderStream())
- .pipeThrough(new EventSourceParserStream())
- .getReader();
- currIndex.value = 0;
- while (true) {
- const x = await reader?.read();
- if (x) {
- const { done, value } = x;
- console.log(x, 999);
- try {
- const val = JSON.parse(value?.data || '');
- const d = val?.data;
- if (typeof d !== 'boolean') {
- console.info('data:', d);
- streamStr.value = d.content;
- startDisplayStr();
+ const reader = response?.body
+ ?.pipeThrough(new TextDecoderStream())
+ .pipeThrough(new EventSourceParserStream())
+ .getReader();
+ currIndex.value = 0;
+ while (true) {
+ const x = await reader?.read();
+ if (x) {
+ const { done, value } = x;
+ console.log(x, 999);
+ try {
+ const val = JSON.parse(value?.data || '');
+ const d = val?.data;
+ if (typeof d !== 'boolean') {
+ console.info('data:', d);
+ streamStr.value = d.content;
+ startDisplayStr();
+ }
+ } catch (e) {
+ console.warn(e);
}
- } catch (e) {
- console.warn(e);
- }
- if (done) {
- console.info('done');
- displayedText.value = '';
- queryAgentSessionDetail(agentObj.id);
- break;
+ if (done) {
+ console.info('done');
+ displayedText.value = '';
+ queryAgentSessionDetail(agentObj.id);
+ break;
+ }
}
}
- }
- chatDis.value = false;
- loading.value = false;
- inputMsg.value = '';
-}
-// 璋冪敤get鏂规硶
-const queryAgentSessionDetail = async (id) => {
- const { code, data } = await getAgentSessionDetailsApi(id);
- if (code == 0) {
- console.log(data,'agent浼氳瘽璇︽儏');
- Object.assign(chatObj, data);
- sessionDetailList.value = data.dsl.messages;
- agentTitle.value = `${data.title}` || '鏈懡鍚嶄細璇�';
- from.name = `${data.title}` || '鏈懡鍚嶄細璇�';
- refreshScroll(); //鍒锋柊婊氬姩鏉′綅缃�
- }
-};
-
-// 鍘嗗彶璁板綍璺宠浆鑾峰彇agent浼氳瘽璇︽儏
-const querySessionDetail = async (session) => {
- conversation_id.value = session.id;
- from.name = session.name;
- const { code, data } = await getSessionDetailsApi(session.id);
- if (code == 200) {
- sessionDetailList.value = data.message.messages;
- const res = await getAgentSessionDetailsApi(session.dialog_id);
- if (res.code == 0) {
- console.log(res.data,'agent浼氳瘽璇︽儏');
- Object.assign(agentObj, res.data);
- Object.assign(chatObj, res.data);
- Object.assign(dsl, res.data.dsl);
+ chatDis.value = false;
+ loading.value = false;
+ inputMsg.value = '';
+ };
+ // 璋冪敤get鏂规硶
+ const queryAgentSessionDetail = async (id) => {
+ const { code, data } = await getAgentSessionDetailsApi(id);
+ if (code == 0) {
+ console.log(data, 'agent浼氳瘽璇︽儏');
+ Object.assign(chatObj, data);
+ sessionDetailList.value = data.dsl.messages;
+ agentTitle.value = `${data.title}` || '鏈懡鍚嶄細璇�';
+ from.name = `${data.title}` || '鏈懡鍚嶄細璇�';
refreshScroll(); //鍒锋柊婊氬姩鏉′綅缃�
}
- }
-};
+ };
-
-const { toClipboard } = useClipboard();
-const copy = async (text) => {
- await toClipboard(text); //鍙傛暟涓鸿澶嶅埗鐨勬枃鏈�
-}
-
-
-const sentClick = () => {
- sendMessage('click');
-};
-
-// 閲嶆柊鐢熸垚
-const reGenerate = () => {
- let inputContent = sessionDetailList.value[sessionDetailList.value.length-2].content
- startChat(inputContent)
-};
-
-const sendMessage = async (event) => {
- if (event.keyCode == 13 || event === 'click') {
- if (!event.shiftKey) {
- //鍙湁enter娌℃湁shift锛屾垨杩涜浣犵殑鍏朵粬閫昏緫
- if (event !== 'click') {
- event.preventDefault(); // 闃绘榛樿琛屼负锛屽嵆涓嶆崲琛�
- }
-
- // chatDis.value = true;
- // loading.value = true;
- // if (!agentObj.id) {
- // Message.warning('璇烽�夋嫨浼氳瘽');
- // chatDis.value = false;
- // loading.value = false;
- // return;
- // }
-
- // if (displayedText.value) {
- // querySessionList();
- // }
-
- if (inputMsg.value) {
- startChat(inputMsg.value)
- inputMsg.value = '';
- } else {
- Message.warning('娑堟伅涓嶈兘涓虹┖');
- chatDis.value = false;
- loading.value = false;
+ // 鍘嗗彶璁板綍璺宠浆鑾峰彇agent浼氳瘽璇︽儏
+ const querySessionDetail = async (session) => {
+ conversation_id.value = session.id;
+ from.name = session.name;
+ const { code, data } = await getSessionDetailsApi(session.id);
+ if (code == 200) {
+ sessionDetailList.value = data.message.messages;
+ const res = await getAgentSessionDetailsApi(session.dialog_id);
+ if (res.code == 0) {
+ console.log(res.data, 'agent浼氳瘽璇︽儏');
+ Object.assign(agentObj, res.data);
+ Object.assign(chatObj, res.data);
+ Object.assign(dsl, res.data.dsl);
+ refreshScroll(); //鍒锋柊婊氬姩鏉′綅缃�
}
}
- }
-};
+ };
+ const { toClipboard } = useClipboard();
+ const copy = async (text) => {
+ await toClipboard(text); //鍙傛暟涓鸿澶嶅埗鐨勬枃鏈�
+ };
-const startChat = async(valMsg)=>{
- sessionDetailList.value.push({
- content: valMsg,
- role: 'user',
- });
- sessionDetailList.value.push({ role: 'last' });
- refreshScroll();
- let chatStr = {
- id: agentObj.id,
- message: valMsg,
- }
- if(isHistory.value){
- chatStr.dsl = dsl;
- }
- const response = await fetch(
- '/api/v1/canvas/completion',
- {
+ const sentClick = () => {
+ sendMessage('click');
+ };
+
+ // 閲嶆柊鐢熸垚
+ const reGenerate = () => {
+ let inputContent =
+ sessionDetailList.value[sessionDetailList.value.length - 2].content;
+ startChat(inputContent);
+ };
+
+ const sendMessage = async (event) => {
+ if (event.keyCode == 13 || event === 'click') {
+ if (!event.shiftKey) {
+ //鍙湁enter娌℃湁shift锛屾垨杩涜浣犵殑鍏朵粬閫昏緫
+ if (event !== 'click') {
+ event.preventDefault(); // 闃绘榛樿琛屼负锛屽嵆涓嶆崲琛�
+ }
+
+ // chatDis.value = true;
+ // loading.value = true;
+ // if (!agentObj.id) {
+ // Message.warning('璇烽�夋嫨浼氳瘽');
+ // chatDis.value = false;
+ // loading.value = false;
+ // return;
+ // }
+
+ // if (displayedText.value) {
+ // querySessionList();
+ // }
+
+ if (inputMsg.value) {
+ startChat(inputMsg.value);
+ inputMsg.value = '';
+ } else {
+ Message.warning('娑堟伅涓嶈兘涓虹┖');
+ chatDis.value = false;
+ loading.value = false;
+ }
+ }
+ }
+ };
+
+ const startChat = async (valMsg) => {
+ sessionDetailList.value.push({
+ content: valMsg,
+ role: 'user',
+ });
+ sessionDetailList.value.push({ role: 'last' });
+ refreshScroll();
+ let chatStr = {
+ id: agentObj.id,
+ message: valMsg,
+ };
+ if (isHistory.value) {
+ chatStr.dsl = dsl;
+ }
+ const response = await fetch('/api/v1/canvas/completion', {
method: 'POST',
headers: {
'Authorization': getAuthorization(),
'Content-Type': 'application/json',
},
body: JSON.stringify(chatStr),
+ });
+
+ const reader = response?.body
+ ?.pipeThrough(new TextDecoderStream())
+ .pipeThrough(new EventSourceParserStream())
+ .getReader();
+ currIndex.value = 0;
+ while (true) {
+ const x = await reader?.read();
+ if (x) {
+ const { done, value } = x;
+ // console.log(x, 999);
+ try {
+ const val = JSON.parse(value?.data || '');
+ const d = val?.data;
+ if (typeof d !== 'boolean') {
+ console.info('data:', d);
+ streamStr.value = d.content;
+ startDisplayStr();
+ }
+ } catch (e) {
+ console.warn(e);
+ }
+ if (done) {
+ console.info('done');
+ displayedText.value = '';
+ if (isStopChat.value) {
+ isStopChat.value = false;
+ setChatDataMeg(chatDataMeg);
+ } else {
+ queryAgentSessionDetail(agentObj.id);
+ EventBus.emit('queryAppUsageList');
+ }
+ break;
+ }
+ }
+ }
+ chatDis.value = false;
+ loading.value = false;
+ };
+
+ const stopChat = async () => {
+ // const { code, data } = await stopChatApi(agentObj.id);
+ // if (code === 200) {
+ // Message.success("宸插仠姝�");
+ // }
+ loading.value = false;
+ chatDis.value = false;
+ isStopChat.value = true;
+ console.log('stopChat');
+ console.log(displayedText.value, 'displayedText');
+ console.log(sessionDetailList.value, 'sessionDetailList');
+ let inputText =
+ sessionDetailList.value[sessionDetailList.value.length - 2].content;
+ // 鏁扮粍鍚堝苟
+ let lastArr = [
+ {
+ content: inputText,
+ role: 'user',
+ },
+ {
+ content: displayedText.value,
+ role: 'assistant',
+ },
+ ];
+ sessionDetailList.value = sessionDetailList.value
+ .splice(0, sessionDetailList.value.length - 2)
+ .concat(lastArr);
+ console.log(sessionDetailList.value, 'sessionDetailList2');
+ console.log(chatObj, 'chatObj瀵硅薄');
+ chatObj.dsl.messages = chatObj.dsl.messages.concat(lastArr);
+ Object.assign(chatDataMeg, {
+ id: chatObj.id,
+ conversation_id: chatObj.id,
+ message: sessionDetailList.value,
+ });
+ };
+
+ const setChatDataMeg = async (chatData) => {
+ const { code, data } = await addSessionApi(chatData);
+ if (data) {
+ //鍋滄瀹氭椂鍣�
+ clearTimeout(timer!);
+ timer = null;
+ // displayedText.value = "";
+ queryAgentSessionDetail(chatObj.id);
+ }
+ };
+
+ const handleShiftEnter = (event) => {
+ event.preventDefault();
+ inputMsg.value += '\n';
+ };
+
+ //鏂囧瓧鍔ㄦ�佽緭鍑�
+ const startDisplayStr = () => {
+ if (timer) {
+ clearTimeout(timer!);
+ }
+ const res = streamStr.value;
+ // 灏嗘暟缁勪腑鐨勫瓧绗︿覆鎷兼帴璧锋潵
+ if (currIndex.value < res.length) {
+ displayedText.value += res[currIndex.value];
+ currIndex.value++;
+ setTimeout(startDisplayStr, 100);
+ refreshScroll();
+ } else {
+ clearTimeout(timer!);
+ timer = null;
+ }
+ };
+
+ const scrollbar = ref(null);
+ const refreshScroll = () => {
+ nextTick(() => {
+ const container = document.getElementById('agentHome');
+ scrollbar.value.scrollTop(container.scrollHeight);
+ });
+ };
+
+ onMounted(() => {
+ EventBus.on('createAgent', (data) => {
+ createNewAgent(data);
+ });
+ EventBus.on('queryAgentSessionDetail', (data) => {
+ isHistory.value = true;
+ querySessionDetail(data);
+ });
+ });
+ onBeforeUnmount(() => {
+ EventBus.off('createAgent');
+ EventBus.off('queryAgentSessionDetail');
+ });
+
+ watch(
+ () => props.modalObj,
+ (newVal, oldVal) => {
+ // Object.assign(agentObj, newVal);
+ //璋冪敤agent鍒濆鍖栨柟娉�
+ if (JSON.stringify(newVal) != '{}') {
+ // initPage();
+ }
+ },
+ {
+ immediate: true,
+ deep: true,
}
);
-
- const reader = response?.body
- ?.pipeThrough(new TextDecoderStream())
- .pipeThrough(new EventSourceParserStream())
- .getReader();
- currIndex.value = 0;
- while (true) {
- const x = await reader?.read();
- if (x) {
- const { done, value } = x;
- // console.log(x, 999);
- try {
- const val = JSON.parse(value?.data || '');
- const d = val?.data;
- if (typeof d !== 'boolean') {
- console.info('data:', d);
- streamStr.value = d.content;
- startDisplayStr();
- }
- } catch (e) {
- console.warn(e);
- }
- if (done) {
- console.info('done');
- displayedText.value = '';
- if (isStopChat.value) {
- isStopChat.value = false;
- setChatDataMeg(chatDataMeg);
- } else {
- queryAgentSessionDetail(agentObj.id);
- EventBus.emit('queryAppUsageList');
- }
- break;
- }
- }
- }
- chatDis.value = false;
- loading.value = false;
-}
-
-const stopChat=async()=>{
- // const { code, data } = await stopChatApi(agentObj.id);
- // if (code === 200) {
- // Message.success("宸插仠姝�");
- // }
- loading.value = false;
- chatDis.value = false;
- isStopChat.value = true;
- console.log('stopChat');
- console.log(displayedText.value, 'displayedText');
- console.log(sessionDetailList.value, 'sessionDetailList');
- let inputText = sessionDetailList.value[sessionDetailList.value.length-2].content
- // 鏁扮粍鍚堝苟
- let lastArr = [{
- content: inputText,
- role: "user"
- },{
- content: displayedText.value,
- role: "assistant"
- }]
- sessionDetailList.value = sessionDetailList.value.splice(0, sessionDetailList.value.length-2).concat(lastArr);
- console.log(sessionDetailList.value, 'sessionDetailList2');
- console.log(chatObj, 'chatObj瀵硅薄');
- chatObj.dsl.messages = chatObj.dsl.messages.concat(lastArr);
- Object.assign(chatDataMeg, {
- id: chatObj.id,
- conversation_id: chatObj.id,
- message: sessionDetailList.value,
- });
-
-}
-
-
-const setChatDataMeg = async (chatData) => {
- const { code, data } = await addSessionApi(chatData);
- if (data) {
- //鍋滄瀹氭椂鍣�
- clearTimeout(timer!);
- timer = null;
- // displayedText.value = "";
- queryAgentSessionDetail(chatObj.id);
- }
-};
-
-const handleShiftEnter = (event) => {
- event.preventDefault();
- inputMsg.value += '\n';
-};
-
-
-
-//鏂囧瓧鍔ㄦ�佽緭鍑�
-const startDisplayStr = () => {
- if (timer) {
- clearTimeout(timer!);
- }
- const res = streamStr.value;
- // 灏嗘暟缁勪腑鐨勫瓧绗︿覆鎷兼帴璧锋潵
- if (currIndex.value < res.length) {
- displayedText.value += res[currIndex.value];
- currIndex.value++;
- setTimeout(startDisplayStr, 100);
- refreshScroll();
- } else {
- clearTimeout(timer!);
- timer = null;
- }
-};
-
-const scrollbar = ref(null);
-const refreshScroll = () => {
- nextTick(() => {
- const container = document.getElementById('agentHome');
- scrollbar.value.scrollTop(container.scrollHeight);
- });
-};
-
-
-onMounted(() => {
- EventBus.on('createAgent', (data) => {
- createNewAgent(data);
- });
- EventBus.on('queryAgentSessionDetail', (data) => {
- isHistory.value = true;
- querySessionDetail(data);
- });
-});
-onBeforeUnmount(() => {
- EventBus.off('createAgent');
- EventBus.off('queryAgentSessionDetail');
-});
-
-watch(
- () => props.modalObj,
- (newVal, oldVal) => {
- // Object.assign(agentObj, newVal);
- //璋冪敤agent鍒濆鍖栨柟娉�
- if(JSON.stringify(newVal) != '{}'){
- // initPage();
- }
- },{
- immediate: true,
- deep: true
- }
-);
</script>
<style scoped lang="scss">
+ .dark {
+ color: gray !important;
+ }
-.dark {
- color: gray !important;
-}
-
-.container {
- .chatItemAnswer {
- box-sizing: border-box;
- background: #f1f1f1;
- border-radius: 14px;
- .light {
+ .container {
+ .chatItemAnswer {
box-sizing: border-box;
background: #f1f1f1;
border-radius: 14px;
- }
- }
- .textItemAnswer {
- background-color: #373739;
- }
-
- .center {
- box-sizing: border-box;
- height: calc(100vh - 200px);
- position: relative;
-
- .center-title {
- line-height: 60px;
- font-size: 25px;
- font-family: 榛戜綋;
- color: deepskyblue;
- }
-
- .center-content {
- font-size: 14px;
- color: gray;
- }
-
- .center-question {
- margin-top: 20px;
- display: flex;
- justify-content: space-between;
-
- .center-question-left {
- margin-top: 5px;
- margin-left: 20px;
- }
-
- .center-question-right {
- margin-right: 20px;
+ .light {
+ box-sizing: border-box;
+ background: #f1f1f1;
+ border-radius: 14px;
}
}
- .center-list {
- margin-top: 10px;
+ .textItemAnswer {
+ background-color: #373739;
+ }
- .item {
- border-radius: 10px;
- margin-top: 10px;
- padding: 10px;
- min-height: 120px;
- background-color: #e9f3ff;
- .item-content {
- color: #666;
- }
- .item-title {
- text-align: center;
- line-height: 40px;
- font-size: 20px;
- font-family: 榛戜綋;
- color: #333;
- }
+ .center {
+ box-sizing: border-box;
+ height: calc(100vh - 200px);
+ position: relative;
+
+ .center-title {
+ line-height: 60px;
+ font-size: 25px;
+ font-family: 榛戜綋;
+ color: deepskyblue;
}
- }
- .chartStart {
- color: #4955f5;
- cursor: pointer;
- font-family: PingFangSC-Medium;
- font-size: 12px;
- font-weight: 500;
- }
- .chat_bottom {
- display: flex;
- align-items: center;
- width: 78%;
- margin: 0 auto;
- .center-bottom {
- // position: absolute;
- // width: 90%;
- // bottom: 20px;
- // left: 5%;
- background: #fff;
- border: 1px solid #00000014;
- border-radius: 24px;
+
+ .center-content {
+ font-size: 14px;
+ color: gray;
+ }
+
+ .center-question {
+ margin-top: 20px;
display: flex;
- flex: 1 1;
- flex-direction: column;
- overflow: hidden;
- position: relative;
- // padding-top:10px;
- :deep(.arco-textarea-wrapper) {
+ justify-content: space-between;
+
+ .center-question-left {
+ margin-top: 5px;
+ margin-left: 20px;
+ }
+
+ .center-question-right {
+ margin-right: 20px;
+ }
+ }
+ .center-list {
+ margin-top: 10px;
+
+ .item {
+ border-radius: 10px;
+ margin-top: 10px;
+ padding: 10px;
+ min-height: 120px;
+ background-color: #e9f3ff;
+ .item-content {
+ color: #666;
+ }
+ .item-title {
+ text-align: center;
+ line-height: 40px;
+ font-size: 20px;
+ font-family: 榛戜綋;
+ color: #333;
+ }
+ }
+ }
+ .chartStart {
+ color: #4955f5;
+ cursor: pointer;
+ font-family: PingFangSC-Medium;
+ font-size: 12px;
+ font-weight: 500;
+ }
+ .chat_bottom {
+ display: flex;
+ align-items: center;
+ width: 78%;
+ margin: 0 auto;
+ .center-bottom {
+ // position: absolute;
+ // width: 90%;
+ // bottom: 20px;
+ // left: 5%;
+ background: #fff;
+ border: 1px solid #00000014;
border-radius: 24px;
- }
+ display: flex;
+ flex: 1 1;
+ flex-direction: column;
+ overflow: hidden;
+ position: relative;
+ // padding-top:10px;
+ :deep(.arco-textarea-wrapper) {
+ border-radius: 24px;
+ }
- .btn-send {
- position: absolute !important;
- right: 4px;
- top: 80px;
- z-index: 10;
+ .btn-send {
+ position: absolute !important;
+ right: 4px;
+ top: 80px;
+ z-index: 10;
+ }
+ :deep(.arco-btn-size-large) {
+ height: 28px;
+ width: 50px;
+ }
}
- :deep(.arco-btn-size-large) {
- height: 28px;
- width: 50px;
+ :deep(.arco-textarea-wrapper) {
+ padding-top: 5px;
}
}
- :deep(.arco-textarea-wrapper) {
- padding-top: 5px;
+ }
+ .chat-item {
+ padding: 10px 0;
+ .chartUserText {
+ font-weight: 600;
+ font-size: 14px;
+ color: #333;
+ margin-top: 4px;
+ }
+ .icon-user-jpg {
+ border: 1px solid #d9d9d9;
}
}
}
- .chat-item {
- padding: 10px 0;
- .chartUserText {
- font-weight: 600;
- font-size: 14px;
- color: #333;
- margin-top: 4px;
- }
- .icon-user-jpg {
- border: 1px solid #d9d9d9;
- }
- }
-}
-.header___lEPyH {
- width: 100%;
- height: 46px;
- position: relative;
- backdrop-filter: blur(15px);
- display: flex;
- align-items: center;
- justify-content: center;
- -webkit-backdrop-filter: blur(15px);
- .chatHeaderBox {
- width: auto;
- border-radius: 8px;
- padding: 4px 20px;
- transition: all var(--animation-duration) var(--animation-transition);
+ .header___lEPyH {
+ width: 100%;
+ height: 46px;
+ position: relative;
+ backdrop-filter: blur(15px);
display: flex;
- align-items: flex-end;
- overflow: hidden; /* 闅愯棌瓒呭嚭鐨勫唴瀹� */
- text-overflow: ellipsis; /* 浣跨敤鐪佺暐鍙锋潵浠f浛琚殣钘忕殑鏂囧瓧 */
- white-space: nowrap; /* 涓嶆崲琛岋紝浣垮唴瀹瑰湪涓�琛屽唴鏄剧ず */
- max-width: 200px;
- .title{
- color: var(--color-text-1);
- font-size: 12px;
+ align-items: center;
+ justify-content: center;
+ -webkit-backdrop-filter: blur(15px);
+ .chatHeaderBox {
+ width: auto;
+ border-radius: 8px;
+ padding: 4px 20px;
+ transition: all var(--animation-duration) var(--animation-transition);
+ display: flex;
+ align-items: flex-end;
+ overflow: hidden; /* 闅愯棌瓒呭嚭鐨勫唴瀹� */
+ text-overflow: ellipsis; /* 浣跨敤鐪佺暐鍙锋潵浠f浛琚殣钘忕殑鏂囧瓧 */
+ white-space: nowrap; /* 涓嶆崲琛岋紝浣垮唴瀹瑰湪涓�琛屽唴鏄剧ず */
+ max-width: 200px;
+ .title {
+ color: var(--color-text-1);
+ font-size: 12px;
+ }
}
}
-}
-.action {
- cursor: pointer;
- display: inline-block;
- padding: 0 10px;
- color: var(--color-text-1);
- line-height: 24px;
- background: transparent;
- border-radius: 2px;
- cursor: pointer;
- transition: all 0.1s ease;
- font-size: 12px;
-}
-.action:hover {
- background: var(--color-fill-3);
-}
+ .action {
+ cursor: pointer;
+ display: inline-block;
+ padding: 0 10px;
+ color: var(--color-text-1);
+ line-height: 24px;
+ background: transparent;
+ border-radius: 2px;
+ cursor: pointer;
+ transition: all 0.1s ease;
+ font-size: 12px;
+ }
+ .action:hover {
+ background: var(--color-fill-3);
+ }
</style>
diff --git a/src/views/sessionManager/components/chatMenu.vue b/src/views/sessionManager/components/chatMenu.vue
index 0744d8e..79fdf84 100644
--- a/src/views/sessionManager/components/chatMenu.vue
+++ b/src/views/sessionManager/components/chatMenu.vue
@@ -4,239 +4,256 @@
<div class="myAgent___djnd_ myAgentAnim myAgentlight___yK7Gk">
<div data-testid="msh-sidebar-main" class="myAgentHome___PG6IZ"></div>
<div class="myAgentLine___Isl6E"></div>
- <div class="myAgentTool___Y1_mC" data-testid="msh-sidebar-new" @click="()=>{
- EventBus.emit('newChat')
- }">
+ <div
+ class="myAgentTool___Y1_mC"
+ data-testid="msh-sidebar-new"
+ @click="
+ () => {
+ EventBus.emit('newChat');
+ }
+ "
+ >
<div class="myAgentToolIcon___gaAKI myAgentToolIconNew___DBZrW">
- <img
- src="@/assets/images/talk.png"
- style="width: 24px"
- alt="">
+ <img src="@/assets/images/talk.png" style="width: 24px" alt="" />
</div>
</div>
- <div data-testid="msh-sidebar-history" class="myAgentTool___Y1_mC" @click="()=>{
- EventBus.emit('history')
- }">
- <div class="myAgentToolIcon___gaAKI myAgentToolIconHistory___GTLWk" >
+ <div
+ data-testid="msh-sidebar-history"
+ class="myAgentTool___Y1_mC"
+ @click="
+ () => {
+ EventBus.emit('history');
+ }
+ "
+ >
+ <div class="myAgentToolIcon___gaAKI myAgentToolIconHistory___GTLWk">
<img
src="@/assets/images/historybg.png"
style="width: 24px"
- alt="">
+ alt=""
+ />
</div>
</div>
- <div data-testid="msh-sidebar-square" class="myAgentTool___Y1_mC myAgentToolSquare___dbLm1" @click="()=>{
- EventBus.emit('smartAi')
- }">
- <div class="myAgentToolIcon___gaAKI myAgentToolIconSquare___Rj1o_"><img
- src="@/assets/images/agent.png"
- style="width: 24px"
- alt=""></div>
+ <div
+ data-testid="msh-sidebar-square"
+ class="myAgentTool___Y1_mC myAgentToolSquare___dbLm1"
+ @click="
+ () => {
+ EventBus.emit('smartAi');
+ }
+ "
+ >
+ <div class="myAgentToolIcon___gaAKI myAgentToolIconSquare___Rj1o_"
+ ><img src="@/assets/images/agent.png" style="width: 24px" alt=""
+ /></div>
</div>
- <div class="myAgentLine___Isl6E" style="margin-top: 4px;"></div>
+ <div class="myAgentLine___Isl6E" style="margin-top: 4px"></div>
<div id="myAgentBox">
-<!-- <div class="myAgentBox___zrCit">-->
-<!-- <div class="myAgentBoxImg___Mgu9e">-->
-<!-- <div class="myAgentBoxImgLayout___u69B_">-->
-<!-- <div class="MuiBox-root css-5nczy5"><img-->
-<!-- src="https://kimi-img.moonshot.cn/prod-chat-kimi/avatar/kimiplus/academic.png" alt=""-->
-<!-- style="border-radius: 50%; width: 100%; height: 100%;"></div>-->
-<!-- <span class="myAgentBoxImgLayoutTip___xHV4m">瀛︽湳鎼滅储</span></div>-->
-<!-- <div data-testid="msh-sidebar-bot-delete" class="myAgentBoxImgDelete___qXZuq">-->
-<!-- <div class="myAgentBoxImgDeleteInner____Hawc">浠庝晶杈规爮绉婚櫎</div>-->
-<!-- </div>-->
-<!-- </div>-->
-<!-- </div>-->
-<!-- <div class="myAgentBox___zrCit">-->
-<!-- <div class="myAgentBoxImg___Mgu9e">-->
-<!-- <div class="myAgentBoxImgLayout___u69B_">-->
-<!-- <div class="MuiBox-root css-5nczy5"><img-->
-<!-- src="https://kimi-img.moonshot.cn/prod-chat-kimi/avatar/kimiplus/paper_rewrite.png" alt=""-->
-<!-- style="border-radius: 50%; width: 100%; height: 100%;"></div>-->
-<!-- <span class="myAgentBoxImgLayoutTip___xHV4m">璁烘枃鏀瑰啓</span></div>-->
-<!-- <div data-testid="msh-sidebar-bot-delete" class="myAgentBoxImgDelete___qXZuq">-->
-<!-- <div class="myAgentBoxImgDeleteInner____Hawc">浠庝晶杈规爮绉婚櫎</div>-->
-<!-- </div>-->
-<!-- </div>-->
-<!-- </div>-->
-<!-- <div class="myAgentBox___zrCit">-->
-<!-- <div class="myAgentBoxImg___Mgu9e">-->
-<!-- <div class="myAgentBoxImgLayout___u69B_">-->
-<!-- <div class="MuiBox-root css-5nczy5"><img-->
-<!-- src="https://kimi-img.moonshot.cn/prod-chat-kimi/avatar/kimiplus/prompt.png" alt=""-->
-<!-- style="border-radius: 50%; width: 100%; height: 100%;"></div>-->
-<!-- <span class="myAgentBoxImgLayoutTip___xHV4m">鎻愮ず璇嶄笓瀹�</span></div>-->
-<!-- <div data-testid="msh-sidebar-bot-delete" class="myAgentBoxImgDelete___qXZuq">-->
-<!-- <div class="myAgentBoxImgDeleteInner____Hawc">浠庝晶杈规爮绉婚櫎</div>-->
-<!-- </div>-->
-<!-- </div>-->
-<!-- </div>-->
-<!-- <div class="myAgentBox___zrCit">-->
-<!-- <div class="myAgentBoxImg___Mgu9e">-->
-<!-- <div class="myAgentBoxImgLayout___u69B_">-->
-<!-- <div class="MuiBox-root css-5nczy5"><img-->
-<!-- src="https://kimi-img.moonshot.cn/prod-chat-kimi/avatar/kimiplus/taro.png" alt=""-->
-<!-- style="border-radius: 50%; width: 100%; height: 100%;"></div>-->
-<!-- <span class="myAgentBoxImgLayoutTip___xHV4m">濉旂綏甯�</span></div>-->
-<!-- <div data-testid="msh-sidebar-bot-delete" class="myAgentBoxImgDelete___qXZuq">-->
-<!-- <div class="myAgentBoxImgDeleteInner____Hawc">浠庝晶杈规爮绉婚櫎</div>-->
-<!-- </div>-->
-<!-- </div>-->
-<!-- </div>-->
+ <!-- <div class="myAgentBox___zrCit">-->
+ <!-- <div class="myAgentBoxImg___Mgu9e">-->
+ <!-- <div class="myAgentBoxImgLayout___u69B_">-->
+ <!-- <div class="MuiBox-root css-5nczy5"><img-->
+ <!-- src="https://kimi-img.moonshot.cn/prod-chat-kimi/avatar/kimiplus/academic.png" alt=""-->
+ <!-- style="border-radius: 50%; width: 100%; height: 100%;"></div>-->
+ <!-- <span class="myAgentBoxImgLayoutTip___xHV4m">瀛︽湳鎼滅储</span></div>-->
+ <!-- <div data-testid="msh-sidebar-bot-delete" class="myAgentBoxImgDelete___qXZuq">-->
+ <!-- <div class="myAgentBoxImgDeleteInner____Hawc">浠庝晶杈规爮绉婚櫎</div>-->
+ <!-- </div>-->
+ <!-- </div>-->
+ <!-- </div>-->
+ <!-- <div class="myAgentBox___zrCit">-->
+ <!-- <div class="myAgentBoxImg___Mgu9e">-->
+ <!-- <div class="myAgentBoxImgLayout___u69B_">-->
+ <!-- <div class="MuiBox-root css-5nczy5"><img-->
+ <!-- src="https://kimi-img.moonshot.cn/prod-chat-kimi/avatar/kimiplus/paper_rewrite.png" alt=""-->
+ <!-- style="border-radius: 50%; width: 100%; height: 100%;"></div>-->
+ <!-- <span class="myAgentBoxImgLayoutTip___xHV4m">璁烘枃鏀瑰啓</span></div>-->
+ <!-- <div data-testid="msh-sidebar-bot-delete" class="myAgentBoxImgDelete___qXZuq">-->
+ <!-- <div class="myAgentBoxImgDeleteInner____Hawc">浠庝晶杈规爮绉婚櫎</div>-->
+ <!-- </div>-->
+ <!-- </div>-->
+ <!-- </div>-->
+ <!-- <div class="myAgentBox___zrCit">-->
+ <!-- <div class="myAgentBoxImg___Mgu9e">-->
+ <!-- <div class="myAgentBoxImgLayout___u69B_">-->
+ <!-- <div class="MuiBox-root css-5nczy5"><img-->
+ <!-- src="https://kimi-img.moonshot.cn/prod-chat-kimi/avatar/kimiplus/prompt.png" alt=""-->
+ <!-- style="border-radius: 50%; width: 100%; height: 100%;"></div>-->
+ <!-- <span class="myAgentBoxImgLayoutTip___xHV4m">鎻愮ず璇嶄笓瀹�</span></div>-->
+ <!-- <div data-testid="msh-sidebar-bot-delete" class="myAgentBoxImgDelete___qXZuq">-->
+ <!-- <div class="myAgentBoxImgDeleteInner____Hawc">浠庝晶杈规爮绉婚櫎</div>-->
+ <!-- </div>-->
+ <!-- </div>-->
+ <!-- </div>-->
+ <!-- <div class="myAgentBox___zrCit">-->
+ <!-- <div class="myAgentBoxImg___Mgu9e">-->
+ <!-- <div class="myAgentBoxImgLayout___u69B_">-->
+ <!-- <div class="MuiBox-root css-5nczy5"><img-->
+ <!-- src="https://kimi-img.moonshot.cn/prod-chat-kimi/avatar/kimiplus/taro.png" alt=""-->
+ <!-- style="border-radius: 50%; width: 100%; height: 100%;"></div>-->
+ <!-- <span class="myAgentBoxImgLayoutTip___xHV4m">濉旂綏甯�</span></div>-->
+ <!-- <div data-testid="msh-sidebar-bot-delete" class="myAgentBoxImgDelete___qXZuq">-->
+ <!-- <div class="myAgentBoxImgDeleteInner____Hawc">浠庝晶杈规爮绉婚櫎</div>-->
+ <!-- </div>-->
+ <!-- </div>-->
+ <!-- </div>-->
<div class="myAgentBox___zrCit" v-for="item in sessionList">
<div class="myAgentBoxImg___Mgu9e" @click="createNewSession(item)">
<div class="myAgentBoxImgLayout___u69B_">
<div class="MuiBox-root css-5nczy5">
<img
- :src="item.icon ? httpUrl + item.icon:imgSrc"
+ :src="item.icon ? httpUrl + item.icon : imgSrc"
alt=""
- style="border-radius: 50%; width: 100%; height: 100%;">
+ style="border-radius: 50%; width: 100%; height: 100%"
+ />
</div>
- <span class="myAgentBoxImgLayoutTip___xHV4m">{{item.name}}</span>
+ <span class="myAgentBoxImgLayoutTip___xHV4m">{{
+ item.name
+ }}</span>
</div>
- <div data-testid="msh-sidebar-bot-delete" class="myAgentBoxImgDelete___qXZuq" @click.stop="deleteSession(item)">
- <div class="myAgentBoxImgDeleteInner____Hawc" >浠庝晶杈规爮绉婚櫎</div>
+ <div
+ data-testid="msh-sidebar-bot-delete"
+ class="myAgentBoxImgDelete___qXZuq"
+ @click.stop="deleteSession(item)"
+ >
+ <div class="myAgentBoxImgDeleteInner____Hawc">浠庝晶杈规爮绉婚櫎</div>
</div>
</div>
</div>
</div>
-<!-- <div class="myAgentLine___Isl6E" style="margin-top: 4px;"></div>-->
+ <!-- <div class="myAgentLine___Isl6E" style="margin-top: 4px;"></div>-->
</div>
</div>
</div>
</template>
<script setup lang="ts">
-import {
- IconClose,
- IconSearch,
- IconTiktokColor
-} from "@arco-design/web-vue/es/icon";
-import { useAppStore, useUserStore } from "@/store";
-import { computed, nextTick, onMounted, watch, reactive, ref, onBeforeMount, onBeforeUnmount } from "vue";
-import {
- addSessionApi,
- chatApi,
- getDialogListApi,
- getSessionDetailsApi,
- deleteSessionApi,
- sessionListApi
-} from "@/api/session";
-import { Message } from "@arco-design/web-vue";
-const httpUrl = localStorage.getItem('httpUrl');
-import EventBus from '@/utils/EventBus';
-const emit = defineEmits(["querySessionDetail","changeAgentType","createSession"]);
-import { appUsageSessionListApi, deleteAppUsage } from "@/api/Agent";
-import { getAgentSessionDetailsApi } from "@/api/agentSession";
-const activeSessionId = ref("");
-const fieldNames = { value: "id", label: "name" };
-const dialogs = ref([]);
-const dialogObj = reactive({});
-const agentObj = reactive({});
-const agentList = ref([]);
-const searchValue = ref("");
-const selectValue = ref("");
-const sectionList = ref({});
-const sessionList = ref([]); //鐢ㄦ埛鎿嶄綔浼氳瘽鍒楄〃
-import img1 from '@/assets/images/talkbg.png'
-import logo from "@/assets/images/model.png";
-const imgSrc = ref(logo);
+ import {
+ IconClose,
+ IconSearch,
+ IconTiktokColor,
+ } from '@arco-design/web-vue/es/icon';
+ import { useAppStore, useUserStore } from '@/store';
+ import {
+ computed,
+ nextTick,
+ onMounted,
+ watch,
+ reactive,
+ ref,
+ onBeforeMount,
+ onBeforeUnmount,
+ } from 'vue';
+ import {
+ addSessionApi,
+ chatApi,
+ getDialogListApi,
+ getSessionDetailsApi,
+ deleteSessionApi,
+ sessionListApi,
+ } from '@/api/session';
+ import { Message } from '@arco-design/web-vue';
+ const httpUrl = localStorage.getItem('httpUrl');
+ import EventBus from '@/utils/EventBus';
+ const emit = defineEmits([
+ 'querySessionDetail',
+ 'changeAgentType',
+ 'createSession',
+ ]);
+ import { appUsageSessionListApi, deleteAppUsage } from '@/api/Agent';
+ import { getAgentSessionDetailsApi } from '@/api/agentSession';
+ const activeSessionId = ref('');
+ const fieldNames = { value: 'id', label: 'name' };
+ const dialogs = ref([]);
+ const dialogObj = reactive({});
+ const agentObj = reactive({});
+ const agentList = ref([]);
+ const searchValue = ref('');
+ const selectValue = ref('');
+ const sectionList = ref({});
+ const sessionList = ref([]); //鐢ㄦ埛鎿嶄綔浼氳瘽鍒楄〃
+ import img1 from '@/assets/images/talkbg.png';
+ import logo from '@/assets/images/model.png';
+ const imgSrc = ref(logo);
-
-
-// 鏌ヨ鍘嗗彶鐢ㄦ埛涔犳儻浼氳瘽鍒楄〃
-const querySessionList = async (id) => {
- const { code, data } = await appUsageSessionListApi('');
- if (code === 200) {
- sessionList.value = data.map((item) => {
- return {
- ...item,
- }
- });
- // sessionList.value.splice(0, 5);
- console.log(sessionList.value,'鐢ㄦ埛涔犳儻浼氳瘽鍒楄〃');
- } else {
- // Message.warning("鏌ヨ澶辫触");
- }
-};
-
-
-// 鏂板浼氳瘽
-const createNewSession = async (session) => {
- console.log(session, 'session');
- // 鏌ヨ鍘嗗彶璁板綍
- if (session.app_type == '1') {
- // 鐢熸垚鏅鸿兘浣撴柊鐨勫璇�
- emit('createSession',session.app_id,`鍜�${session.name}鐨勪細璇漙);
- emit('changeAgentType','1');
- } else {
- // 鐢熸垚agent鏂扮殑瀵硅瘽
- // agent瀵硅薄鏁版嵁灏佽
- const { code, data } = await getAgentSessionDetailsApi(session.app_id);
- if (code == 0) {
- console.log(data,'浼氳瘽璇︽儏');
- let sessionObj = {
- id: session.app_id,
- dsl: data.dsl,
- title: session.name,
- }
- EventBus.emit("createAgent",sessionObj);
- emit('changeAgentType','2');
- }
-
- }
-
-
-
-}
-
-
-
-
-//鏍规嵁浼氳瘽id鍒犻櫎浼氳瘽
-const deleteSession = async (session) => {
- const { code } = await deleteAppUsage({
- app_id:session.app_id
- });
- if (code === 200) {
- // Message.success('鍒犻櫎鎴愬姛');
+ // 鏌ヨ鍘嗗彶鐢ㄦ埛涔犳儻浼氳瘽鍒楄〃
+ const querySessionList = async (id) => {
const { code, data } = await appUsageSessionListApi('');
if (code === 200) {
- sessionList.value = data;
+ sessionList.value = data.map((item) => {
+ return {
+ ...item,
+ };
+ });
// sessionList.value.splice(0, 5);
- console.log(sessionList.value,'鐢ㄦ埛涔犳儻浼氳瘽鍒楄〃');
- if(sessionList.value.length == 0){
- // 鐢熸垚鏅鸿兘浣撴柊鐨勫璇�
- emit('createSession','');
- emit('changeAgentType','1');
- }
+ console.log(sessionList.value, '鐢ㄦ埛涔犳儻浼氳瘽鍒楄〃');
} else {
// Message.warning("鏌ヨ澶辫触");
}
- }
-};
+ };
+ // 鏂板浼氳瘽
+ const createNewSession = async (session) => {
+ console.log(session, 'session');
+ // 鏌ヨ鍘嗗彶璁板綍
+ if (session.app_type == '1') {
+ // 鐢熸垚鏅鸿兘浣撴柊鐨勫璇�
+ emit('createSession', session.app_id, `鍜�${session.name}鐨勪細璇漙);
+ emit('changeAgentType', '1');
+ } else {
+ // 鐢熸垚agent鏂扮殑瀵硅瘽
+ // agent瀵硅薄鏁版嵁灏佽
+ const { code, data } = await getAgentSessionDetailsApi(session.app_id);
+ if (code == 0) {
+ console.log(data, '浼氳瘽璇︽儏');
+ let sessionObj = {
+ id: session.app_id,
+ dsl: data.dsl,
+ title: session.name,
+ };
+ EventBus.emit('createAgent', sessionObj);
+ emit('changeAgentType', '2');
+ }
+ }
+ };
+ //鏍规嵁浼氳瘽id鍒犻櫎浼氳瘽
+ const deleteSession = async (session) => {
+ const { code } = await deleteAppUsage({
+ app_id: session.app_id,
+ });
+ if (code === 200) {
+ // Message.success('鍒犻櫎鎴愬姛');
+ const { code, data } = await appUsageSessionListApi('');
+ if (code === 200) {
+ sessionList.value = data;
+ // sessionList.value.splice(0, 5);
+ console.log(sessionList.value, '鐢ㄦ埛涔犳儻浼氳瘽鍒楄〃');
+ if (sessionList.value.length == 0) {
+ // 鐢熸垚鏅鸿兘浣撴柊鐨勫璇�
+ emit('createSession', '');
+ emit('changeAgentType', '1');
+ }
+ } else {
+ // Message.warning("鏌ヨ澶辫触");
+ }
+ }
+ };
-
-
-
-onBeforeMount(()=>{
- querySessionList('');
-})
-
-onMounted(() => {
- EventBus.on("queryAppUsageList", (data) => {
+ onBeforeMount(() => {
querySessionList('');
- })
-})
-onBeforeUnmount(() => {
- EventBus.off("queryAppUsageList");
-});
+ });
-
-
+ onMounted(() => {
+ EventBus.on('queryAppUsageList', (data) => {
+ querySessionList('');
+ });
+ });
+ onBeforeUnmount(() => {
+ EventBus.off('queryAppUsageList');
+ });
</script>
<style scoped lang="less">
- @import "@/views/sessionManager/style/layout.css";
+ @import '@/views/sessionManager/style/layout.css';
.layoutNavMoveCenter {
display: flex;
justify-content: center;
@@ -244,13 +261,9 @@
height: calc(100vh - 160px); /* 鎴栬�呮寚瀹氶珮搴� */
position: relative;
}
- #myAgentBox{
+ #myAgentBox {
//width: 100%;
//max-height: 220px;
//overflow: hidden;
}
-
-
-
-
</style>
diff --git a/src/views/sessionManager/components/smartAi.vue b/src/views/sessionManager/components/smartAi.vue
index 8d1ef3c..4059e8f 100644
--- a/src/views/sessionManager/components/smartAi.vue
+++ b/src/views/sessionManager/components/smartAi.vue
@@ -1,191 +1,188 @@
<template>
<div class="layoutAgentCenter">
- <a-scrollbar
- style="
- height: calc(100vh - 100px);
- overflow-y: auto;
- overflow-x: hidden;
- "
- >
- <div class="search">
- <!-- 鏌ヨ妗�-->
- <img src="@/assets/images/his.png"
- style="width: 100%"
- alt="">
-
- </div>
- <div class="agentMainCenter">
- <a-row class="agentCenter">
- <a-col :span="8" v-for="item in dialogs">
- <div
- class="item agentCenter-box"
- @click="createNewSession(item)"
- >
- <div class="text" >
- <a-avatar>
- <img
- :style="{ width: '100%' }"
- alt="dessert"
- :src="item.avatar || imgSrc"
- />
- </a-avatar>
- <span style="margin-left: 10px;font-weight: 500;color: var(--color-text-1)">
- {{ item.name }}
- </span>
- </div>
- <div class="time"
- >
- </div>
- </div>
- </a-col>
- <a-col :span="8" v-for="item in agentList">
- <div
- class="item agentCenter-box"
- @click="createNewSession(item)"
- >
- <div class="text" >
- <a-avatar>
- <img
- :style="{ width: '100%' }"
- alt="dessert"
- :src="item.avatar || imgSrc"
- />
- </a-avatar>
- <span style="margin-left: 10px;font-weight: 500;color: var(--color-text-1)">
- {{ item.name }}
- </span>
- </div>
- <div class="time"
- >
- </div>
- </div>
- </a-col>
- </a-row>
- </div>
- </a-scrollbar>
+ <a-scrollbar
+ style="height: calc(100vh - 100px); overflow-y: auto; overflow-x: hidden"
+ >
+ <div class="search">
+ <!-- 鏌ヨ妗�-->
+ <img src="@/assets/images/his.png" style="width: 100%" alt="" />
+ </div>
+ <div class="agentMainCenter">
+ <a-row class="agentCenter">
+ <a-col :span="8" v-for="item in dialogs">
+ <div class="item agentCenter-box" @click="createNewSession(item)">
+ <div class="text">
+ <a-avatar>
+ <img
+ :style="{ width: '100%' }"
+ alt="dessert"
+ :src="item.icon || imgSrc"
+ />
+ </a-avatar>
+ <span
+ style="
+ margin-left: 10px;
+ font-weight: 500;
+ color: var(--color-text-1);
+ "
+ >
+ {{ item.name }}
+ </span>
+ </div>
+ <div class="time"> </div>
+ </div>
+ </a-col>
+ <a-col :span="8" v-for="item in agentList">
+ <div class="item agentCenter-box" @click="createNewSession(item)">
+ <div class="text">
+ <a-avatar>
+ <img
+ :style="{ width: '100%' }"
+ alt="dessert"
+ :src="item.avatar || imgSrc"
+ />
+ </a-avatar>
+ <span
+ style="
+ margin-left: 10px;
+ font-weight: 500;
+ color: var(--color-text-1);
+ "
+ >
+ {{ item.name }}
+ </span>
+ </div>
+ <div class="time"> </div>
+ </div>
+ </a-col>
+ </a-row>
+ </div>
+ </a-scrollbar>
</div>
</template>
<script setup lang="ts">
-import {
- IconClose,
- IconSearch,
- IconTiktokColor
-} from "@arco-design/web-vue/es/icon";
-import { useAppStore, useUserStore } from "@/store";
-import { computed, nextTick, onMounted, watch, reactive, ref, onBeforeMount, onBeforeUnmount } from "vue";
+ import {
+ IconClose,
+ IconSearch,
+ IconTiktokColor,
+ } from '@arco-design/web-vue/es/icon';
+ import { useAppStore, useUserStore } from '@/store';
+ import {
+ computed,
+ nextTick,
+ onMounted,
+ watch,
+ reactive,
+ ref,
+ onBeforeMount,
+ onBeforeUnmount,
+ } from 'vue';
-import { Message } from "@arco-design/web-vue";
-import EventBus from '@/utils/EventBus';
-import moment from "moment";
-import {
- addSessionApi,
- chatApi,
- getDialogListApi,
- getSessionDetailsApi,
- sessionListApi
-} from "@/api/session";
-import { queryCanvasList } from "@/api/Agent";
-const emit = defineEmits(["querySessionDetail","changeAgentType","createSession"]);
-import logo from "@/assets/images/model.png";
-const sessionList = ref([]); //浼氳瘽鍒楄〃
-const activeSessionId = ref("");
-const fieldNames = { value: "id", label: "name" };
-const dialogs = ref([]);
-const dialogObj = reactive({});
-const agentObj = reactive({});
-const agentList = ref([]);
-const searchValue = ref("");
-const selectValue = ref("");
-const sectionList = ref({});
-const imgSrc = ref(logo);
-const DialogList = async () => {
- const { code, data } = await getDialogListApi();
- if (code === 200) {
- if (data?.length>0) {
- selectValue.value = data[0].id;
- dialogs.value = data.map((item) => {
+ import { Message } from '@arco-design/web-vue';
+ import EventBus from '@/utils/EventBus';
+ import moment from 'moment';
+ import {
+ addSessionApi,
+ chatApi,
+ getDialogListApi,
+ getSessionDetailsApi,
+ sessionListApi,
+ } from '@/api/session';
+ import { queryCanvasList } from '@/api/Agent';
+ const emit = defineEmits([
+ 'querySessionDetail',
+ 'changeAgentType',
+ 'createSession',
+ ]);
+ import logo from '@/assets/images/model.png';
+ const sessionList = ref([]); //浼氳瘽鍒楄〃
+ const activeSessionId = ref('');
+ const fieldNames = { value: 'id', label: 'name' };
+ const dialogs = ref([]);
+ const dialogObj = reactive({});
+ const agentObj = reactive({});
+ const agentList = ref([]);
+ const searchValue = ref('');
+ const selectValue = ref('');
+ const sectionList = ref({});
+ const imgSrc = ref(logo);
+ const DialogList = async () => {
+ const { code, data } = await getDialogListApi();
+ if (code === 200) {
+ if (data?.length > 0) {
+ selectValue.value = data[0].id;
+ dialogs.value = data.map((item) => {
+ return {
+ ...item,
+ type: 1, //鏅鸿兘浣�
+ };
+ });
+ // console.log(dialogs, 'dialogs');
+ }
+ }
+ };
+
+ const queryCanvas = async (params = {}) => {
+ try {
+ const { data } = await queryCanvasList(params);
+
+ agentList.value = data.map((item) => {
return {
...item,
- type: 1 //鏅鸿兘浣�
+ name: item.title,
+ type: 2, //agent
};
});
- // console.log(data, "dialogs");
-
+ // console.log(agentList, 'agent');
+ // 鍚堝苟鏁扮粍
+ // dialogs.value = dialogs.value.concat(agentList.value);
+ } catch (err) {
+ // you can report use errorHandler or other
+ } finally {
}
- }
-};
+ };
-const queryCanvas = async (params = {}) => {
- try {
- const { data } = await queryCanvasList(params);
- console.log(data, "agent");
- agentList.value = data.map((item) => {
- return {
- ...item,
- name: item.title,
- type: 2 //agent
- };
- });
- // 鍚堝苟鏁扮粍
- // dialogs.value = dialogs.value.concat(agentList.value);
-
-
- } catch (err) {
- // you can report use errorHandler or other
- } finally {
- }
-};
-
-
-// 鏌ヨ浼氳瘽鍒楄〃
-const querySessionList = async (id) => {
- const { code, data } = await sessionListApi(id);
- if (code === 200) {
- sessionList.value = data;
-
-
-
- } else {
- Message.warning("鏌ヨ澶辫触");
- }
-};
-// 鐢熸垚鏅鸿兘浣撴柊寤轰細璇�
-const createNewSession = async (session) => {
- console.log(session, 'session');
- // emit('querySessionDetail',session);
- if (session.type == '1') {
- // 鐢熸垚鏅鸿兘浣撴柊鐨勫璇�
- emit('createSession',session.id,`鍜�${session.name}鐨勪細璇漙);
- emit('changeAgentType','1');
- } else {
- // 鐢熸垚agent鏂扮殑瀵硅瘽
- EventBus.emit("createAgent",session);
- emit('changeAgentType','2');
- }
-
-
-
-}
-onBeforeMount(()=>{
- DialogList();
- queryCanvas();
-})
-
-onMounted(() => {
- EventBus.on("smartAi", () => {
- emit('changeAgentType','4');
+ // 鏌ヨ浼氳瘽鍒楄〃
+ const querySessionList = async (id) => {
+ const { code, data } = await sessionListApi(id);
+ if (code === 200) {
+ sessionList.value = data;
+ } else {
+ Message.warning('鏌ヨ澶辫触');
+ }
+ };
+ // 鐢熸垚鏅鸿兘浣撴柊寤轰細璇�
+ const createNewSession = async (session) => {
+ console.log(session, 'session');
+ // emit('querySessionDetail',session);
+ if (session.type == '1') {
+ // 鐢熸垚鏅鸿兘浣撴柊鐨勫璇�
+ emit('createSession', session.id, `鍜�${session.name}鐨勪細璇漙);
+ emit('changeAgentType', '1');
+ } else {
+ // 鐢熸垚agent鏂扮殑瀵硅瘽
+ EventBus.emit('createAgent', session);
+ emit('changeAgentType', '2');
+ }
+ };
+ onBeforeMount(() => {
DialogList();
queryCanvas();
});
-})
-onBeforeUnmount(() => {
- EventBus.off("smartAi");
-});
-
+ onMounted(() => {
+ EventBus.on('smartAi', () => {
+ emit('changeAgentType', '4');
+ DialogList();
+ queryCanvas();
+ });
+ });
+ onBeforeUnmount(() => {
+ EventBus.off('smartAi');
+ });
</script>
<style scoped lang="less">
- .layoutAgentCenter{
+ .layoutAgentCenter {
width: 100%;
//background: #999999;
position: absolute;
@@ -197,9 +194,9 @@
font-weight: 700;
text-align: center;
}
- .search{
+ .search {
width: 100%;
- .search-box{
+ .search-box {
width: 70%;
margin-left: 15%;
border: 1px solid var(--color-text-4);
@@ -208,19 +205,19 @@
background: var(--color-bg-2);
margin-top: 20px;
margin-bottom: 20px;
- :deep(.arco-input-wrapper){
+ :deep(.arco-input-wrapper) {
border: none;
background: var(--color-bg-2);
}
}
}
- .agentMainCenter{
+ .agentMainCenter {
width: 70%;
margin: 0 auto;
- .agentCenter{
+ .agentCenter {
width: 100%;
margin-top: 30px;
- .agentCenter-box{
+ .agentCenter-box {
display: flex;
width: 90%;
margin: 0 auto;
@@ -234,20 +231,14 @@
align-items: center;
color: var(--color-text-2);
}
- .agentCenter-box:hover{
+ .agentCenter-box:hover {
color: var(--color-text-2);
//border: 1px solid var(--color-neutral-3);
background: var(--color-bg-3);
- box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);
+ box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16),
+ 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);
}
}
}
-
-
-
-
}
-
-
-
</style>
diff --git a/src/views/sessionManager/index.vue b/src/views/sessionManager/index.vue
index 94c0d2a..d140f21 100644
--- a/src/views/sessionManager/index.vue
+++ b/src/views/sessionManager/index.vue
@@ -87,42 +87,65 @@
<template #avatar>
<img
class="icon-user-jpg"
- src="../../assets/images/icon-chart.png"
+ src="../../assets/images/icon-picture.png"
alt="鏈湴鍥剧墖"
/>
</template>
<template #content>
<a-card v-if="isExistTip(sessionDetail.content)">
- <div :class="{ chatItemAnswer: theme === 'light' }"
- :style="{backgroundColor: theme === 'light' ? '#ffffff' : '#000000'}" style="border: none;display: inline;" v-for="(item,tipIndex) in tipMatch(sessionDetail)"
+ <div
+ :class="{ chatItemAnswer: theme === 'light' }"
+ :style="{
+ backgroundColor:
+ theme === 'light' ? '#ffffff' : '#000000',
+ }"
+ style="border: none; display: inline"
+ v-for="(item, tipIndex) in tipMatch(sessionDetail)"
>
<span v-if="tipIndex == 0">
{{ sessionDetail.content.substring(0, item.index) }}
- <a-tooltip background-color="#3491FA" :content="getTipContent(
- messagenList.reference,
- index
- )">
- <img style="width: 20px;height: 20px" :src="tipImage" />
+ <a-tooltip
+ background-color="#3491FA"
+ :content="
+ getTipContent(messagenList.reference, index)
+ "
+ >
+ <img
+ style="width: 20px; height: 20px"
+ :src="tipImage"
+ />
</a-tooltip>
</span>
<span v-else>
- {{ sessionDetail.content.substring(item.preIndex+item.item.length, item.index) }}
- <a-tooltip background-color="#3491FA" :content="getTipContent(
- messagenList.reference,
- index
- )">
- <img style="width: 20px;height: 20px" :src="tipImage" />
+ {{
+ sessionDetail.content.substring(
+ item.preIndex + item.item.length,
+ item.index
+ )
+ }}
+ <a-tooltip
+ background-color="#3491FA"
+ :content="
+ getTipContent(messagenList.reference, index)
+ "
+ >
+ <img
+ style="width: 20px; height: 20px"
+ :src="tipImage"
+ />
</a-tooltip>
</span>
-
</div>
</a-card>
- <a-card v-else>
- <div :class="{ chatItemAnswer: theme === 'light' }"
- :style="{
- backgroundColor:
- theme === 'light' ? '#ffffff' : '#000000',
- }" style="border: none">
+ <a-card v-else>
+ <div
+ :class="{ chatItemAnswer: theme === 'light' }"
+ :style="{
+ backgroundColor:
+ theme === 'light' ? '#ffffff' : '#000000',
+ }"
+ style="border: none"
+ >
{{ sessionDetail.content }}
</div>
</a-card>
@@ -174,7 +197,7 @@
<template #avatar>
<img
class="icon-user-jpg"
- src="../../assets/images/icon-chart.png"
+ src="../../assets/images/icon-picture.png"
alt="鏈湴鍥剧墖"
/>
</template>
@@ -389,7 +412,7 @@
</div>
</template>
<script setup lang="ts">
-import { useAppStore, userModelState, useUserStore } from "@/store";
+ import { useAppStore, userModelState, useUserStore } from '@/store';
import {
computed,
nextTick,
@@ -419,20 +442,20 @@
sessionListApi,
uploadWithoutKb,
} from '@/api/session';
-import { getAuthorization } from "@/utils/auth";
-import { queryCanvasList } from "@/api/Agent";
-import { getAgentSessionDetailsApi } from "@/api/agentSession";
-import useClipboard from "vue-clipboard3";
-import pdfImg1 from "@/assets/session/PDF.png";
-import pdfImg2 from "@/assets/session/wps-write.png";
-import pdfImg3 from "@/assets/session/execl.png";
-import pdfImg4 from "@/assets/session/icon-txt.png";
-import pdfImg5 from "@/assets/session/txt.png";
-import tipImage from "@/assets/session/tip.png";
+ import { getAuthorization } from '@/utils/auth';
+ import { queryCanvasList } from '@/api/Agent';
+ import { getAgentSessionDetailsApi } from '@/api/agentSession';
+ import useClipboard from 'vue-clipboard3';
+ import pdfImg1 from '@/assets/session/PDF.png';
+ import pdfImg2 from '@/assets/session/wps-write.png';
+ import pdfImg3 from '@/assets/session/execl.png';
+ import pdfImg4 from '@/assets/session/icon-txt.png';
+ import pdfImg5 from '@/assets/session/txt.png';
+ import tipImage from '@/assets/session/tip.png';
-import docx from "@/views/dmx/knowledgeLib/components/docx.vue";
-import excel from "@/views/dmx/knowledgeLib/components/excel.vue";
-import txtPdf from "@/views/dmx/knowledgeLib/components/txtPdf.vue";
+ import docx from '@/views/dmx/knowledgeLib/components/docx.vue';
+ import excel from '@/views/dmx/knowledgeLib/components/excel.vue';
+ import txtPdf from '@/views/dmx/knowledgeLib/components/txtPdf.vue';
// const url = ref('../../assets/session/PDF.png');
@@ -481,8 +504,7 @@
let documenttype = ref('docx');
let previewSrc = ref('');
-
-const modelStore = userModelState();
+ const modelStore = userModelState();
const httpUrl = modelStore.hrefUrl;
const rules = {
@@ -509,25 +531,25 @@
}
};
let dataItem = [];
- const isExistTip=(message:string):boolean=>{
+ const isExistTip = (message: string): boolean => {
if (/##[0-9]\$\$/.test(message)) {
return true;
} else {
return false;
}
- }
+ };
const tipMatch = (session: any): any[] => {
//match session.content涓殑##[0-9]$$鐨勭储寮�
let indexs: any[] = [];
- let preTip=0;
+ let preTip = 0;
session.content.match(/##([0-9]+)\$\$/g)?.map((item) => {
let i = session.content.indexOf(item);
indexs.push({ index: i, item: item, preIndex: preTip });
preTip = i;
});
return indexs;
- }
+ };
const getTxt = (data, role, message, index) => {
if (isExistTip(message)) {
@@ -543,16 +565,15 @@
};
const getTipContent = (data, index): string => {
- let maxSimilarityContent = "";
+ let maxSimilarityContent = '';
let i = index / 2 - 1 > 0 ? index / 2 - 1 : 0;
let maxSimilarity = 0;
data[i].chunks.forEach((chunk) => {
- if (chunk.similarity > maxSimilarity) {
- maxSimilarity = chunk.similarity;
- maxSimilarityContent = chunk.content_with_weight;
- }
+ if (chunk.similarity > maxSimilarity) {
+ maxSimilarity = chunk.similarity;
+ maxSimilarityContent = chunk.content_with_weight;
}
- );
+ });
return maxSimilarityContent;
};
@@ -623,10 +644,7 @@
const selectFileCallback = (data) => {
console.log(data, 'selectFileCallback');
- uploaditemList.value = [
- ...uploaditemList.value,
- ...data
- ];
+ uploaditemList.value = [...uploaditemList.value, ...data];
};
let onFileSelectedLoading = ref(false);
@@ -744,7 +762,9 @@
if (res.code == 200) {
// console.log(res.data.conversation_id);
activeSessionId.value = res.data?.conversation_id;
- const { code, data } = await getSessionDetailsApi(res.data?.conversation_id);
+ const { code, data } = await getSessionDetailsApi(
+ res.data?.conversation_id
+ );
if (code === 200) {
console.log(data, '鏂板缓浼氳瘽璇︽儏');
Object.assign(chatObj, data);
--
Gitblit v1.8.0