From b9bfd6535e15d700f469c25008dfb323e28dbfaa Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期二, 27 八月 2024 14:23:25 +0800
Subject: [PATCH] fix: 修改bug

---
 src/views/dmx/knowledgeLib/test.vue                |  376 ++++++++++++++++++++-----------------
 src/views/sessionManager/index.vue                 |  191 ++++++++++++------
 src/views/sessionManager/components/updataFile.vue |    3 
 3 files changed, 330 insertions(+), 240 deletions(-)

diff --git a/src/views/dmx/knowledgeLib/test.vue b/src/views/dmx/knowledgeLib/test.vue
index 4dae6dc..0156658 100644
--- a/src/views/dmx/knowledgeLib/test.vue
+++ b/src/views/dmx/knowledgeLib/test.vue
@@ -1,202 +1,232 @@
-
 <template>
-    <div class="main-container">
-      <div class="main-container-lf">
-        <div class="main-container-lf-top">妫�绱㈡祴璇�</div>
-        <div class="main-container-lf-down">
-          <div style="color: #999;">鏈�鍚庝竴姝ワ紒 鎴愬姛鍚庯紝鍓╀笅鐨勫氨浜ょ粰Infiniflow AI鍚с��</div>
-          <a-divider style="margin-top: 10px" />
-          <a-form ref="formRef"  :model="form" :style="{width:'100%'}" layout="vertical"  @submit="handleSubmit">
-            <a-form-item field="similarity_threshold" label="鐩镐技搴﹂槇鍊�">
-              <a-slider v-model="form.similarity_threshold" :step="0.01" :min="0" :max="1"  />
-            </a-form-item>
-            <a-form-item field="slider" label="鍏抽敭瀛楃浉浼煎害鏉冮噸" >
-              <a-slider v-model="form.vector_similarity_weight" :step="0.01" :min="0" :max="1"  />
-            </a-form-item>
-            <a-form-item field="section" label="Rerank妯″瀷" >
-              <a-space direction="vertical" size="large">
-                <a-select :size="'large'" v-model="form.rerank_id" :style="{width:'100%'}" placeholder="璇烽�夋嫨 ..." allow-clear>
-                  <a-optgroup  :label="index" v-for="(item,index) in modelList" :key=index>
-                    <a-option
-                      v-for="(obj) in item"
-                      :key="obj.fid"
-                      :disabled="!obj.available"
-                      :value="obj.llm_name"
-                    >
-                      {{obj.llm_name}}
-                    </a-option>
-                  </a-optgroup>
-                </a-select>
-              </a-space>
-            </a-form-item>
-            <a-form-item field="slider" label="Top-K" v-if="form.rerank_id">
-              <a-slider v-model="form.top_k" :min="1" :max="2048" />
-            </a-form-item>
-            <a-form-item >
-              <div class="main-container-form-item-extra">
-                <div class="main-container-form-item-extra-top">娴嬭瘯鏂囨湰</div>
-                <div class="main-container-form-item-extra-down">
-                  <a-textarea v-model="form.question" style="height: 10rem;border: 1px solid  var(--color-fill-3);border-radius: 4px" placeholder="" allow-clear/>
-                </div>
-                <div class="main-container-form-item-extra-btn">
-                  <a-button :disabled="!form.question" :loading="loading" type="primary" html-type="submit">娴嬭瘯</a-button>
-                </div>
+  <div class="main-container">
+    <div class="main-container-lf">
+      <div class="main-container-lf-top">妫�绱㈡祴璇�</div>
+      <div class="main-container-lf-down">
+        <div style="color: #999"
+          >鏈�鍚庝竴姝ワ紒 鎴愬姛鍚庯紝鍓╀笅鐨勫氨浜ょ粰Infiniflow AI鍚с��</div
+        >
+        <a-divider style="margin-top: 10px" />
+        <a-form
+          ref="formRef"
+          :model="form"
+          :style="{ width: '100%' }"
+          layout="vertical"
+          @submit="handleSubmit"
+        >
+          <a-form-item field="similarity_threshold" label="鐩镐技搴﹂槇鍊�">
+            <a-slider
+              v-model="form.similarity_threshold"
+              :step="0.01"
+              :min="0"
+              :max="1"
+            />
+          </a-form-item>
+          <a-form-item field="slider" label="鍏抽敭瀛楃浉浼煎害鏉冮噸">
+            <a-slider
+              v-model="form.vector_similarity_weight"
+              :step="0.01"
+              :min="0"
+              :max="1"
+            />
+          </a-form-item>
+          <a-form-item field="section" label="Rerank妯″瀷">
+            <a-space direction="vertical" size="large">
+              <a-select
+                :size="'large'"
+                v-model="form.rerank_id"
+                :style="{ width: '100%' }"
+                placeholder="璇烽�夋嫨 ..."
+                allow-clear
+              >
+                <a-optgroup
+                  :label="index"
+                  v-for="(item, index) in modelList"
+                  :key="index"
+                >
+                  <a-option
+                    v-for="obj in item"
+                    :key="obj.fid"
+                    :disabled="!obj.available"
+                    :value="obj.llm_name"
+                  >
+                    {{ obj.llm_name }}
+                  </a-option>
+                </a-optgroup>
+              </a-select>
+            </a-space>
+          </a-form-item>
+          <a-form-item field="slider" label="Top-K" v-if="form.rerank_id">
+            <a-slider v-model="form.top_k" :min="1" :max="2048" />
+          </a-form-item>
+          <a-form-item>
+            <div class="main-container-form-item-extra">
+              <div class="main-container-form-item-extra-top">娴嬭瘯鏂囨湰</div>
+              <div class="main-container-form-item-extra-down">
+                <a-textarea
+                  v-model="form.question"
+                  style="
+                    height: 10rem;
+                    border: 1px solid var(--color-fill-3);
+                    border-radius: 4px;
+                  "
+                  placeholder=""
+                  allow-clear
+                />
               </div>
-            </a-form-item>
-          </a-form>
-        </div>
-      </div>
-      <div class="main-container-rt">
-        <a-collapse style="width: 96%;margin-top: 1rem;margin-left: 2%">
-          <a-collapse-item header="0/0 閫夊畾鐨勬枃浠�" key="3">
-            <template #extra>
-              <a-tag size="small">鍛戒腑鏁�</a-tag>
-              <a-tag size="small">鐪嬫硶</a-tag>
-            </template>
-            <div>
-              <a-empty />
+              <div class="main-container-form-item-extra-btn">
+                <a-button
+                  :disabled="!form.question"
+                  :loading="loading"
+                  type="primary"
+                  html-type="submit"
+                  >娴嬭瘯</a-button
+                >
+              </div>
             </div>
-          </a-collapse-item>
-        </a-collapse>
+          </a-form-item>
+        </a-form>
       </div>
     </div>
+    <div class="main-container-rt">
+      <a-collapse style="width: 96%; margin-top: 1rem; margin-left: 2%">
+        <a-collapse-item header="0/0 閫夊畾鐨勬枃浠�" key="3">
+          <template #extra>
+            <a-tag size="small">鍛戒腑鏁�</a-tag>
+            <a-tag size="small">鐪嬫硶</a-tag>
+          </template>
+          <div>
+            <a-empty />
+          </div>
+        </a-collapse-item>
+      </a-collapse>
+    </div>
+  </div>
 </template>
 
 <script lang="ts" setup>
-import { onMounted, onBeforeMount, reactive, ref, watch } from "vue";
-import { Message } from '@arco-design/web-vue';
-import { kbretrievalTest, queryModelList } from "@/api/kbList";
-// const props = defineProps(['kbId'])
+  import { onMounted, onBeforeMount, reactive, ref, watch } from 'vue';
+  import { Message } from '@arco-design/web-vue';
+  import { kbretrievalTest, queryModelList } from '@/api/kbList';
+  // const props = defineProps(['kbId'])
 
-// watch(() => props.kbId, (newValue, oldValue) => {
-//   console.log('kbId 鍙樺寲浜�', newValue, oldValue);
-// },{
-//   deep:true,
-// });
+  // watch(() => props.kbId, (newValue, oldValue) => {
+  //   console.log('kbId 鍙樺寲浜�', newValue, oldValue);
+  // },{
+  //   deep:true,
+  // });
 
-
-let visible = ref(false);
-let loading = ref(false);
-const formRef = ref(null);
-const kbid = ref('');
-const modelList = ref({});
-let form = reactive({
-  page: 1,
-  question: '',
-  rerank_id: '',
-  similarity_threshold: 0.2,
-  size: 10,
-  top_k: 1024,
-  vector_similarity_weight: 0.7,
-});
-
-
-const formatter = (value) => {
-  // return String(Math.round(value / 100))
-};
-
-const handleSubmit = async ({values, errors}) => {
-  // console.log(props.kbobj, 'props.kbobj');
-  if (!form.question){
-    return
-  }
-  let formObj = {
-    ...form,
-    kb_id:kbid.value,
-    vector_similarity_weight:(1 - form.vector_similarity_weight).toFixed(2),
-  }
-  if(!formObj.rerank_id){
-    delete formObj.top_k;
-    delete formObj.rerank_id;
-  }
-  try {
-    loading.value = true;
-    const data = await kbretrievalTest(formObj);
-    if(data.code == 0){
-      Message.success('娴嬭瘯鎴愬姛');
-    }else{
-      Message.error('娴嬭瘯澶辫触');
-    }
-    loading.value = false;
-  }catch (err){
-    Message.error(err.message);
-    loading.value = false;
-  }
-
-}
-
-const handleClick = () => {
-  visible.value = true;
-};
-const handleCancel = () => {
-  visible.value = false;
-}
-
-const handleOpened =(el) => {
-  Object.assign(form,{
-
+  let visible = ref(false);
+  let loading = ref(false);
+  const formRef = ref(null);
+  const kbid = ref('');
+  const modelList = ref({});
+  let form = reactive({
+    page: 1,
+    question: '',
+    rerank_id: '',
+    similarity_threshold: 0.2,
+    size: 10,
+    top_k: 1024,
+    vector_similarity_weight: 0.7,
   });
-  formRef.value.resetFields();
-}
 
-const changekbid = (value) => {
-  console.log(value, 'kbid鐨剉alue');
-  kbid.value = value;
-}
+  const formatter = (value) => {
+    // return String(Math.round(value / 100))
+  };
 
-const queryModel = async (params) => {
-  try {
-    const data = await queryModelList(params);
-    // console.log(data.data, '澶фā鍨嬪垪琛�');
-    modelList.value = {
-      BAAI: [data.data.BAAI[1]],
-      Jina: data.data.Jina,
-      youdao: data.data.youdao
+  const handleSubmit = async ({ values, errors }) => {
+    // console.log(props.kbobj, 'props.kbobj');
+    if (!form.question) {
+      return;
+    }
+    let formObj = {
+      ...form,
+      kb_id: kbid.value,
+      vector_similarity_weight: parseFloat(
+        (1 - form.vector_similarity_weight).toFixed(2)
+      ),
     };
-  } catch (err) {
-    // you can report use errorHandler or other
-  } finally {
+    if (!formObj.rerank_id) {
+      delete formObj.top_k;
+      delete formObj.rerank_id;
+    }
+    try {
+      loading.value = true;
+      const data = await kbretrievalTest(formObj);
+      if (data.code == 0) {
+        Message.success('娴嬭瘯鎴愬姛');
+      } else {
+        Message.error('娴嬭瘯澶辫触');
+      }
+      loading.value = false;
+    } catch (err) {
+      Message.error(err.message);
+      loading.value = false;
+    }
+  };
 
-  }
-};
+  const handleClick = () => {
+    visible.value = true;
+  };
+  const handleCancel = () => {
+    visible.value = false;
+  };
 
+  const handleOpened = (el) => {
+    Object.assign(form, {});
+    formRef.value.resetFields();
+  };
 
-defineExpose({
-  changekbid
-})
+  const changekbid = (value) => {
+    console.log(value, 'kbid鐨剉alue');
+    kbid.value = value;
+  };
 
-onBeforeMount(()=>{
-  queryModel({})
-})
-onMounted(()=>{
+  const queryModel = async (params) => {
+    try {
+      const data = await queryModelList(params);
+      // console.log(data.data, '澶фā鍨嬪垪琛�');
+      modelList.value = {
+        BAAI: [data.data.BAAI[1]],
+        Jina: data.data.Jina,
+        youdao: data.data.youdao,
+      };
+    } catch (err) {
+      // you can report use errorHandler or other
+    } finally {
+    }
+  };
 
+  defineExpose({
+    changekbid,
+  });
 
-})
-
-
+  onBeforeMount(() => {
+    queryModel({});
+  });
+  onMounted(() => {});
 </script>
 
 <script lang="ts">
-export default {
-  name: 'config',
-  methods: {
-
-  }
-};
+  export default {
+    name: 'config',
+    methods: {},
+  };
 </script>
 <style scoped lang="less">
-  .main-container{
+  .main-container {
     display: flex;
     justify-content: space-between;
     height: 100%;
-    &-lf{
+    &-lf {
       width: 30%;
       height: 100%;
       //border: 1px solid var(--color-fill-3);
       background: var(--color-bg-2);
       border-radius: 10px;
       overflow: auto;
-      &-top{
+      &-top {
         width: 100%;
         height: 60px;
         line-height: 60px;
@@ -204,38 +234,38 @@
         color: #ffffff;
         text-align: center;
       }
-      &-down{
+      &-down {
         padding: 20px;
         width: 100%;
       }
     }
-    &-form-item-extra{
+    &-form-item-extra {
       width: 100%;
       height: 20rem;
       border: 1px solid var(--color-fill-3);
       border-radius: 6px;
       overflow: hidden;
-      &-top{
+      &-top {
         width: 100%;
         height: 40px;
         line-height: 40px;
-        border-bottom: 1px solid  var(--color-fill-3);
+        border-bottom: 1px solid var(--color-fill-3);
         //background: rgb(var(--primary-6));
         color: #999999;
         text-align: center;
       }
-      &-down{
+      &-down {
         width: 92%;
         margin-left: 4%;
         margin-top: 30px;
       }
-      &-btn{
+      &-btn {
         width: 96%;
         text-align: right;
         margin-top: 1rem;
       }
     }
-    &-rt{
+    &-rt {
       width: 69%;
       height: 100%;
       //background: #626aea;
@@ -244,4 +274,4 @@
       border-radius: 10px;
     }
   }
-</style>
\ No newline at end of file
+</style>
diff --git a/src/views/sessionManager/components/updataFile.vue b/src/views/sessionManager/components/updataFile.vue
index a9c1827..0a09f24 100644
--- a/src/views/sessionManager/components/updataFile.vue
+++ b/src/views/sessionManager/components/updataFile.vue
@@ -364,11 +364,12 @@
   const getParseMethodsList = async () => {
     let res = await getParseMethodsListApi();
     parser_ids.value = res.data.map((item) => {
+      console.log(item, item.parser_config_str, 78787);
       return {
         name: item.name,
         value: item.id,
         parser_config: '',
-        parser_config_str: item.parser_config_str,
+        parser_config_str: JSON.stringify(item.formats),
       };
     });
     parser_idsArr.value = res.data;
diff --git a/src/views/sessionManager/index.vue b/src/views/sessionManager/index.vue
index a46713c..e0adb16 100644
--- a/src/views/sessionManager/index.vue
+++ b/src/views/sessionManager/index.vue
@@ -78,9 +78,38 @@
                   />
                 </template>
                 <template #content>
-                  <div :class="{ chartUserText: theme === 'light' }"
-                    >{{ sessionDetail.content }}
+                  <div :class="{ chartUserText: theme === 'light' }">
+                    {{ sessionDetail.content }}
+                    <!-- <a-input
+                      :style="{ width: '100%' }"
+                      v-model="sessionDetail.content"
+                      v-if="isEdit"
+                    />
+
+                    <div v-else>
+                      {{ sessionDetail.content }}
+                    </div> -->
                   </div>
+                  <!-- <div v-if="!isEdit">
+                    <span
+                      class="action"
+                      v-if="index != 0"
+                      @click="copy(sessionDetail.content)"
+                    >
+                      <icon-copy /> 澶嶅埗
+                    </span>
+                    <span class="action" @click="edit()">
+                      <icon-pen /> 缂栬緫
+                    </span>
+                  </div>
+                  <a-space v-else>
+                    <a-button type="outline" size="mini" @click="cancelEdit(1)"
+                      >鍙栨秷</a-button
+                    >
+                    <a-button type="primary" size="mini" @click="cancelEdit(2)"
+                      >纭畾</a-button
+                    >
+                  </a-space> -->
                 </template>
               </a-comment>
               <a-comment v-else-if="sessionDetail.role === 'assistant'">
@@ -99,81 +128,82 @@
                         backgroundColor:
                           theme === 'light' ? '#ffffff' : '#000000',
                       }"
-                      style="border: none;"
-                      v-for="(breakContent, breakIndex) in breakLine(sessionDetail.content)"
+                      style="border: none"
+                      v-for="(breakContent, breakIndex) in breakLine(
+                        sessionDetail.content
+                      )"
                     >
                       <div
                         :class="{ chatItemAnswer: theme === 'light' }"
                         :style="{
-                        backgroundColor:
-                          theme === 'light' ? '#ffffff' : '#000000',
-                      }"
-                        style="border: none;"
-                      v-if="isExistTip(breakContent)">
+                          backgroundColor:
+                            theme === 'light' ? '#ffffff' : '#000000',
+                        }"
+                        style="border: none"
+                        v-if="isExistTip(breakContent)"
+                      >
                         <div
                           :class="{ chatItemAnswer: theme === 'light' }"
                           :style="{
-                        backgroundColor:
-                          theme === 'light' ? '#ffffff' : '#000000',
-                      }"
-                          style="border: none;"
+                            backgroundColor:
+                              theme === 'light' ? '#ffffff' : '#000000',
+                          }"
+                          style="border: none"
                           v-for="(item, tipIndex) in tipMatch(breakContent)"
                         >
-                      <span v-if="tipIndex == 0">
-                        {{ breakContent.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-if ="tipIndex == item.len - 1">
-                        {{
+                          <span v-if="tipIndex == 0">
+                            {{ breakContent.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-if="tipIndex == item.len - 1">
+                            {{
                               breakContent.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>
-                        {{
-                              breakContent.substring(item.index+5)
-                            }}
-                      </span>
+                            <a-tooltip
+                              background-color="#3491FA"
+                              :content="
+                                getTipContent(messagenList.reference, index)
+                              "
+                            >
+                              <img
+                                style="width: 20px; height: 20px"
+                                :src="tipImage"
+                              />
+                            </a-tooltip>
+                            {{ breakContent.substring(item.index + 5) }}
+                          </span>
                           <span v-else>
-                        {{
+                            {{
                               breakContent.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>
+                            <a-tooltip
+                              background-color="#3491FA"
+                              :content="
+                                getTipContent(messagenList.reference, index)
+                              "
+                            >
+                              <img
+                                style="width: 20px; height: 20px"
+                                :src="tipImage"
+                              />
+                            </a-tooltip>
+                          </span>
                         </div>
                       </div>
                       <div v-else>
@@ -185,15 +215,18 @@
                     <a-textarea
                       readonly
                       auto-size
-                      v-model="sessionDetail.content"
+                      :default-value="chartText(sessionDetail.content)"
                       :class="{ chatItemAnswer: theme === 'light' }"
                       :style="{
-                      backgroundColor:
-                        theme === 'light' ? '#ffffff' : '#000000',
-                    }"
+                        backgroundColor:
+                          theme === 'light' ? '#ffffff' : '#000000',
+                      }"
                       style="border: none"
                     >
                     </a-textarea>
+                    <!-- <div v-html="chartText(sessionDetail.content)">
+
+                    </div> -->
                   </a-card>
                 </template>
                 <!-- <div>{{ sessionDetail.role === 'assistant' }}</div> -->
@@ -237,6 +270,7 @@
                   >
                     <icon-refresh /> 閲嶆柊鐢熸垚
                   </span>
+                  <!-- <span class="action"><icon-to-bottom />涓嬭浇 </span> -->
                 </template>
               </a-comment>
               <a-comment v-else-if="sessionDetail.role === 'last'">
@@ -502,7 +536,7 @@
   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 { is } from "immutable";
+  import { is } from 'immutable';
 
   // const url = ref('../../assets/session/PDF.png');
 
@@ -589,17 +623,29 @@
   const breakLine = (message: string): string[] => {
     //鎸塡n鍒嗗壊瀛楃涓�
     let arr = message.split('\n');
-    return arr
-  }
+    return arr;
+  };
+
+  const chartText = (message: string): string => {
+    //鍘婚櫎鎵�鏈夌殑#鍜�**
+    let arr = message.replace(/\*\*|\#\#\#/g, '');
+    return arr;
+  };
 
   const tipMatch = (msg: string): any[] => {
     //match session.content涓殑##[0-9]$$鐨勭储寮�
+
     let indexs: any[] = [];
     let preTip = 0;
-    let matches=msg.match(/##([0-9]+)\$\$/g)
+    let matches = msg.match(/##([0-9]+)\$\$/g);
     matches?.map((item) => {
       let i = msg.indexOf(item);
-      indexs.push({ index: i, item: item, preIndex: preTip, len: matches.length });
+      indexs.push({
+        index: i,
+        item: item,
+        preIndex: preTip,
+        len: matches.length,
+      });
       preTip = i;
     });
     return indexs;
@@ -713,6 +759,19 @@
     await toClipboard(text); //鍙傛暟涓鸿澶嶅埗鐨勬枃鏈�
   };
 
+  const isEdit = ref(false);
+  const edit = () => {
+    isEdit.value = !isEdit.value;
+  };
+  const cancelEdit = (val) => {
+    if (val == 1) {
+      isEdit.value = !isEdit.value;
+    } else {
+      //缂栬緫淇濆瓨
+      isEdit.value = !isEdit.value;
+    }
+  };
+
   const DialogList = async () => {
     const { code, data } = await getDialogListApi();
     if (code === 200) {

--
Gitblit v1.8.0