zhangxiao
2024-08-26 53fd55bdf6544ae9c2697e460766ce2d53044dbe
fix: 修改bug
1个文件已添加
5个文件已修改
628 ■■■■ 已修改文件
config/vite.config.dev.ts 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/images/icon-picture.png 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sessionManager/components/agentSession.vue 190 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sessionManager/components/chatMenu.vue 161 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sessionManager/components/smartAi.vue 137 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sessionManager/index.vue 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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`), ''),
src/assets/images/icon-picture.png
src/views/sessionManager/components/agentSession.vue
@@ -4,18 +4,17 @@
    <div class="chatHeader">
      <div class="chatHeaderBox">
<!--        <span class="title">{{agentTitle}}</span>-->
        <a-popover
          position="bottom"
          trigger="click"
        >
          <a-button border
          >
            <span style="
        <a-popover position="bottom" trigger="click">
          <a-button border>
            <span
              style="
                       width: 100px;
                      overflow: hidden;
                      text-overflow: ellipsis;
                      white-space: nowrap;
                    ">{{ from.name }}</span>
              "
              >{{ from.name }}</span
            >
            <icon-down style="margin-left: 4px" />
          </a-button>
          <template #content>
@@ -66,7 +65,7 @@
        <template #avatar>
          <img
            class="icon-user-jpg"
            src="../../../assets/images/icon-chart.png"
            src="../../../assets/images/icon-picture.png"
            alt="本地图片"
          />
        </template>
@@ -81,16 +80,26 @@
            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)">
          <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()">
          <span
            class="action"
            v-if="index != 0 && index == sessionDetailList.length - 1"
            @click="reGenerate()"
          >
                     <icon-refresh /> 重新生成
                  </span>
        </template>
@@ -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"
          <div
            class="action"
               @click="stopChat"
               style="background: var(--color-bg-2);color: var(--color-primary-light-4);" v-if="displayedText != ''">
            style="
              background: var(--color-bg-2);
              color: var(--color-primary-light-4);
            "
            v-if="displayedText != ''"
          >
            <icon-record-stop />
            停止生成
          </div>
@@ -156,9 +173,8 @@
          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">-->
<!--        &lt;!&ndash; <icon-send size="32" /> &ndash;&gt;-->
@@ -174,7 +190,14 @@
<!--        >-->
<!--      </div>-->
    </div>
    <a-modal v-model:visible="visible" title="修改名称" @before-open="handleOpened" @cancel="handleCancel" :footer="false" title-align="start">
    <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="请输入名称"/>
@@ -182,7 +205,12 @@
        <a-form-item>
          <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,15 +219,29 @@
</template>
<script setup lang="ts">
import { defineProps, ref, watch, defineEmits, onMounted, reactive, computed, nextTick, onBeforeUnmount } from "vue";
  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 { useAppStore } from '@/store';
  import { getAuthorization } from '@/utils/auth';
import { EventSourceParserStream } from 'eventsource-parser/stream';
import { agentResetApi, agentSetApi, getAgentSessionDetailsApi } from "@/api/agentSession";
  import {
    agentResetApi,
    agentSetApi,
    getAgentSessionDetailsApi,
  } from '@/api/agentSession';
import EventBus from '@/utils/EventBus';
import useClipboard from "vue-clipboard3";
import { addSessionApi, getSessionDetailsApi } from "@/api/session";
  import useClipboard from 'vue-clipboard3';
  import { addSessionApi, getSessionDetailsApi } from '@/api/session';
const props = defineProps({
  modalObj: Object,
});
@@ -212,8 +254,7 @@
const dialogId = ref('');
const chatDis = ref(false);
const loading = ref(false);
const agentTitle = ref("未命名会话");
  const agentTitle = ref('未命名会话');
const currIndex = ref(0);
const displayedText = ref(''); // 正在显示的文字
@@ -228,7 +269,7 @@
const selectValue = ref('');
const sectionList = ref({});
let chatObj = reactive({});
const isStopChat = ref(false)
  const isStopChat = ref(false);
const appStore = useAppStore();
const theme = computed(() => {
  return appStore.theme;
@@ -242,7 +283,6 @@
let dsl = reactive({});
const chatDataMeg = reactive({});
const rules = {
  name: [
    {
@@ -250,7 +290,7 @@
      message:'名称不允许为空',
    },
  ],
}
  };
const handleSubmit = async({values, errors}) => {
  if(errors) return;
@@ -258,29 +298,28 @@
  let chatData = {
    id:conversation_id.value,
    conversation_id:conversation_id.value,
    name: from.name
  }
      name: from.name,
    };
  const { code, data } = await addSessionApi(chatData);
  if (data) {
    Message.success("修改成功");
    handleCancel()
      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 () => {
@@ -292,7 +331,7 @@
  Object.assign(agentObj, session);
  isHistory.value = false;
  initPage();
}
  };
// 调用set方法
const agentSet = async () => {
  const res = await agentSetApi({
@@ -305,7 +344,7 @@
    conversation_id.value = res.data.conversation_id;
    agentReset();
  }
}
  };
// 调用reset方法
const agentReset = async () => {
  const res = await agentResetApi({
@@ -315,22 +354,19 @@
    // Message.success('修改成功');
    agentCompletion();
  }
}
  };
// 调用completion方法
const agentCompletion = async () => {
  const response = await fetch(
    '/api/v1/canvas/completion',
    {
    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())
@@ -364,7 +400,7 @@
  chatDis.value = false;
  loading.value = false;
  inputMsg.value = '';
}
  };
// 调用get方法
const queryAgentSessionDetail = async (id) => {
  const { code, data } = await getAgentSessionDetailsApi(id);
@@ -396,12 +432,10 @@
  }
};
const { toClipboard } = useClipboard();
const copy = async (text) => {
  await toClipboard(text);    //参数为要复制的文本
}
  };
const sentClick = () => {
  sendMessage('click');
@@ -409,8 +443,9 @@
// 重新生成
const reGenerate = () => {
  let inputContent = sessionDetailList.value[sessionDetailList.value.length-2].content
  startChat(inputContent)
    let inputContent =
      sessionDetailList.value[sessionDetailList.value.length - 2].content;
    startChat(inputContent);
};
const sendMessage = async (event) => {
@@ -435,7 +470,7 @@
      // }
      if (inputMsg.value) {
        startChat(inputMsg.value)
          startChat(inputMsg.value);
        inputMsg.value = '';
      } else {
        Message.warning('消息不能为空');
@@ -445,7 +480,6 @@
    }
  }
};
const startChat = async(valMsg)=>{
  sessionDetailList.value.push({
@@ -457,21 +491,18 @@
  let chatStr = {
    id: agentObj.id,
    message: valMsg,
  }
    };
  if(isHistory.value){
    chatStr.dsl = dsl;
  }
  const response = await fetch(
    '/api/v1/canvas/completion',
    {
    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())
@@ -510,7 +541,7 @@
  }
  chatDis.value = false;
  loading.value = false;
}
  };
const stopChat=async()=>{
  // const { code, data } = await stopChatApi(agentObj.id);
@@ -523,16 +554,22 @@
  console.log('stopChat');
  console.log(displayedText.value, 'displayedText');
  console.log(sessionDetailList.value, 'sessionDetailList');
  let inputText = sessionDetailList.value[sessionDetailList.value.length-2].content
    let inputText =
      sessionDetailList.value[sessionDetailList.value.length - 2].content;
  // 数组合并
  let lastArr = [{
    let lastArr = [
      {
    content: inputText,
    role: "user"
  },{
        role: 'user',
      },
      {
    content: displayedText.value,
    role: "assistant"
  }]
  sessionDetailList.value = sessionDetailList.value.splice(0, sessionDetailList.value.length-2).concat(lastArr);
        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);
@@ -541,9 +578,7 @@
    conversation_id: chatObj.id,
    message: sessionDetailList.value,
  });
}
  };
const setChatDataMeg = async (chatData) => {
  const { code, data } = await addSessionApi(chatData);
@@ -560,8 +595,6 @@
  event.preventDefault();
  inputMsg.value += '\n';
};
//文字动态输出
const startDisplayStr = () => {
@@ -589,7 +622,6 @@
  });
};
onMounted(() => {
  EventBus.on('createAgent', (data) => {
    createNewAgent(data);
@@ -612,15 +644,15 @@
    if(JSON.stringify(newVal) != '{}'){
      // initPage();
    }
  },{
    },
    {
    immediate: true,
    deep: true
      deep: true,
  }
);
</script>
<style scoped lang="scss">
.dark {
  color: gray !important;
}
src/views/sessionManager/components/chatMenu.vue
@@ -4,35 +4,50 @@
      <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
          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">-->
@@ -89,11 +104,18 @@
                  <img
                    :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
                data-testid="msh-sidebar-bot-delete"
                class="myAgentBoxImgDelete___qXZuq"
                @click.stop="deleteSession(item)"
              >
                <div class="myAgentBoxImgDeleteInner____Hawc"  >从侧边栏移除</div>
              </div>
            </div>
@@ -108,39 +130,50 @@
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";
    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";
    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 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 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";
  import img1 from '@/assets/images/talkbg.png';
  import logo from '@/assets/images/model.png';
const imgSrc = ref(logo);
// 查询历史用户习惯会话列表
const querySessionList = async (id) => {
@@ -149,7 +182,7 @@
    sessionList.value = data.map((item) => {
      return {
        ...item,
      }
        };
    });
    // sessionList.value.splice(0, 5);
    console.log(sessionList.value,'用户习惯会话列表');
@@ -157,7 +190,6 @@
    // Message.warning("查询失败");
  }
};
// 新增会话
const createNewSession = async (session) => {
@@ -177,24 +209,17 @@
        id: session.app_id,
        dsl: data.dsl,
        title: session.name,
      }
      EventBus.emit("createAgent",sessionObj);
        };
        EventBus.emit('createAgent', sessionObj);
      emit('changeAgentType','2');
    }
  }
}
  };
//根据会话id删除会话
const deleteSession = async (session) => {
  const { code } = await deleteAppUsage({
    app_id:session.app_id
      app_id: session.app_id,
  });
  if (code === 200) {
    // Message.success('删除成功');
@@ -214,29 +239,21 @@
  }
};
onBeforeMount(()=>{
  querySessionList('');
})
onMounted(() => {
  EventBus.on("queryAppUsageList", (data) => {
    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;
@@ -249,8 +266,4 @@
    //max-height: 220px;
    //overflow: hidden;
  }
</style>
src/views/sessionManager/components/smartAi.vue
@@ -1,48 +1,39 @@
<template>
  <div class="layoutAgentCenter">
              <a-scrollbar
                style="
                  height: calc(100vh - 100px);
                  overflow-y: auto;
                  overflow-x: hidden;
                "
      style="height: calc(100vh - 100px); overflow-y: auto; overflow-x: hidden"
              >
                <div class="search">
                  <!--                  查询框-->
                  <img src="@/assets/images/his.png"
                       style="width: 100%"
                       alt="">
        <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="item agentCenter-box" @click="createNewSession(item)">
                        <div class="text" >
                          <a-avatar>
                            <img
                              :style="{ width: '100%' }"
                              alt="dessert"
                              :src="item.avatar || imgSrc"
                    :src="item.icon || imgSrc"
                            />
                          </a-avatar>
                          <span style="margin-left: 10px;font-weight: 500;color: var(--color-text-1)">
                <span
                  style="
                    margin-left: 10px;
                    font-weight: 500;
                    color: var(--color-text-1);
                  "
                >
                            {{ item.name }}
                          </span>
                        </div>
                        <div class="time"
                        >
                        </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="item agentCenter-box" @click="createNewSession(item)">
                        <div class="text" >
                          <a-avatar>
                            <img
@@ -51,13 +42,17 @@
                              :src="item.avatar || imgSrc"
                            />
                          </a-avatar>
                          <span style="margin-left: 10px;font-weight: 500;color: var(--color-text-1)">
                <span
                  style="
                    margin-left: 10px;
                    font-weight: 500;
                    color: var(--color-text-1);
                  "
                >
                            {{ item.name }}
                          </span>
                        </div>
                        <div class="time"
                        >
                        </div>
              <div class="time"> </div>
                      </div>
                    </a-col>
                  </a-row>
@@ -69,33 +64,46 @@
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";
    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 { Message } from '@arco-design/web-vue';
import EventBus from '@/utils/EventBus';
import moment from "moment";
  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";
    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 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 searchValue = ref('');
  const selectValue = ref('');
const sectionList = ref({});
const imgSrc = ref(logo);
const DialogList = async () => {
@@ -106,11 +114,10 @@
      dialogs.value = data.map((item) => {
        return {
          ...item,
          type: 1 //智能体
            type: 1, //智能体
        };
      });
      // console.log(data, "dialogs");
        // console.log(dialogs, 'dialogs');
    }
  }
};
@@ -118,35 +125,30 @@
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
          type: 2, //agent
      };
    });
      // console.log(agentList, '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("查询失败");
      Message.warning('查询失败');
  }
};
// 生成智能体新建会话
@@ -159,30 +161,25 @@
    emit('changeAgentType','1');
  } else {
    // 生成agent新的对话
    EventBus.emit("createAgent",session);
      EventBus.emit('createAgent', session);
    emit('changeAgentType','2');
  }
}
  };
onBeforeMount(()=>{
  DialogList();
  queryCanvas();
})
  });
onMounted(() => {
  EventBus.on("smartAi", () => {
    EventBus.on('smartAi', () => {
    emit('changeAgentType','4');
    DialogList();
    queryCanvas();
  });
})
onBeforeUnmount(() => {
  EventBus.off("smartAi");
});
  onBeforeUnmount(() => {
    EventBus.off('smartAi');
  });
</script>
<style scoped lang="less">
  .layoutAgentCenter{
@@ -238,16 +235,10 @@
          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>
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)"
                    >
                      <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>
                      </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" />
                        </a-tooltip>
                      </span>
                    </div>
                  </a-card>
                  <a-card  v-else>
                    <div :class="{ chatItemAnswer: theme === 'light' }"
                    <div
                      :class="{ chatItemAnswer: theme === 'light' }"
                         :style="{
                      backgroundColor:
                        theme === 'light' ? '#ffffff' : '#000000',
                    }" style="border: none">
                      }"
                      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>
                      </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"
                          />
                        </a-tooltip>
                      </span>
                    </div>
                  </a-card>
                  <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,7 +504,6 @@
  let documenttype = ref('docx');
  let previewSrc = ref('');
const modelStore = userModelState();
  const httpUrl = modelStore.hrefUrl;
@@ -515,7 +537,7 @@
    } else {
      return false;
    }
  }
  };
  const tipMatch = (session: any): any[] => {
    //match session.content中的##[0-9]$$的索引
@@ -527,7 +549,7 @@
      preTip = i;
    });
    return indexs;
  }
  };
  const getTxt = (data, role, message, index) => {
    if (isExistTip(message)) {
@@ -543,7 +565,7 @@
  };
  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) => {
@@ -551,8 +573,7 @@
          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);