liudong
2024-08-22 8a3e7d81eeb68094fb2fa89c036a5a0660e0ac7e
src/views/sessionManager/components/agentSession.vue
@@ -3,30 +3,30 @@
  <div class="header___lEPyH">
    <div class="chatHeader">
      <div class="chatHeaderBox">
        <span class="title">{{agentTitle}}</span>
<!--        <a-popover-->
<!--          position="bottom"-->
<!--          trigger="click"-->
<!--        >-->
<!--          <a-button border-->
<!--          >{{agentTitle}}-->
<!--            <icon-down style="margin-left: 4px" />-->
<!--          </a-button>-->
<!--          <template #content>-->
<!--            <a-button-->
<!--              type="text"-->
<!--              class="button"-->
<!--              style="color: #2a2a2b"-->
<!--              @click="handleClick()"-->
<!--            >-->
<!--              <template #icon>-->
<!--                <icon-edit />-->
<!--              </template>-->
<!--              修改名称-->
<!--            </a-button>-->
<!--            &lt;!&ndash;                    <a-divider style="margin: 10px 0" />&ndash;&gt;-->
<!--          </template>-->
<!--        </a-popover>-->
<!--        <span class="title">{{agentTitle}}</span>-->
        <a-popover
          position="bottom"
          trigger="click"
        >
          <a-button border
          >{{agentTitle}}
            <icon-down style="margin-left: 4px" />
          </a-button>
          <template #content>
            <a-button
              type="text"
              class="button"
              style="color: #2a2a2b"
              @click="handleClick()"
            >
              <template #icon>
                <icon-edit />
              </template>
              修改名称
            </a-button>
            <!--                    <a-divider style="margin: 10px 0" />-->
          </template>
        </a-popover>
      </div>
    </div>
  </div>
@@ -141,6 +141,7 @@
                  maxRows: 5,
                }"
      />
      <div style="height: 40px"></div>
      <div class="btn-send">
        <!-- <icon-send size="32" /> -->
        <a-button
@@ -215,6 +216,8 @@
});
const visible = ref(false);
let isHistory = ref(false);//是否是历史记录
let dsl = reactive({});
@@ -232,19 +235,17 @@
  // agentObj.name = agentTitle.value;
  // agentObj.conversation_id = agentObj.id;
  console.log(agentObj, 'agentObj');
  // let chatData = {
  //   id:agentObj.id,
  //   conversation_id:agentObj.id,
  //   name: agentTitle.value
  // }
  // const { code, data } = await addSessionApi(chatData);
  // if (data) {
  //   Message.success("修改成功");
  //   handleCancel()
  //   queryAgentSessionDetail(agentObj.id);
  // }
  let chatData = {
    id:activeSessionId.value,
    conversation_id:activeSessionId.value,
    name: agentTitle.value
  }
  const { code, data } = await addSessionApi(chatData);
  if (data) {
    Message.success("修改成功");
    handleCancel()
    // queryAgentSessionDetail(agentObj.id);
  }
}
const handleClick = () => {
@@ -269,6 +270,7 @@
const createNewAgent = async (session) => {
  Object.assign(agentObj, session);
  isHistory.value = false;
  initPage();
@@ -361,14 +363,22 @@
  }
};
// 获取agent会话详情
const querySessionDetail = async (session) => {
  sectionList.value = session;
  Object.assign(agentObj, session);
  agentObj.id = session.dialog_id;
  activeSessionId.value = session.id;
  agentTitle.value = session.name;
  console.log(agentTitle.value, '会话名称');
  const { code, data } = await getSessionDetailsApi(session.id);
  if (code === 200) {
    sessionDetailList.value = data.message;
    refreshScroll(); //刷新滚动条位置
  if (code == 200) {
    sessionDetailList.value = data.message.messages;
    const res = await getAgentSessionDetailsApi(session.dialog_id);
    if (res.code == 0) {
      console.log(res.data,'会话详情');
      Object.assign(dsl, res.data.dsl);
      refreshScroll(); //刷新滚动条位置
    }
  }
};
@@ -424,13 +434,19 @@
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',
    {
@@ -439,10 +455,7 @@
        'Authorization': getAuthorization(),
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        id: agentObj.id,
        message: valMsg,
      }),
      body: JSON.stringify(chatStr),
    }
  );
@@ -558,8 +571,7 @@
    createNewAgent(data);
  });
  EventBus.on('queryAgentSessionDetail', (data) => {
    Object.assign(agentObj, data);
    // queryAgentSessionDetail(data.id);
    isHistory.value = true;
    querySessionDetail(data);
  });
});