Browse Source

修改部分问题并打包

yangg 8 months ago
parent
commit
df670e9d6f

+ 2 - 2
.env.development

@@ -2,5 +2,5 @@
 ENV = 'development'
 port = 8080
 # base api
-VUE_APP_BASE_API = 'http://183.195.216.54:8084'
-#192.168.1.199
+VUE_APP_BASE_API = 'http://192.168.1.188:8084'
+#192.168.1.200

File diff suppressed because it is too large
+ 0 - 0
dist/index.html


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.337b6f2d.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/chunk-00246418.264d5770.css


+ 0 - 1
dist/static/css/chunk-2e972bd4.c7717360.css

@@ -1 +0,0 @@
-.header[data-v-13784288]{margin-left:20px}.header h2[data-v-13784288]{margin-bottom:0}.center[data-v-13784288]{margin:10px}.center[data-v-13784288] .el-form--inline .el-form-item{display:block}.center[data-v-13784288] .el-input-number--medium{width:150px}.footer[data-v-13784288]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;margin:0 100px 20px}

+ 1 - 0
dist/static/css/chunk-52d27877.24915812.css

@@ -0,0 +1 @@
+.header[data-v-45729730]{margin-left:20px}.header h2[data-v-45729730]{margin-bottom:0}.center[data-v-45729730]{margin:10px}.center[data-v-45729730] .el-form--inline .el-form-item{display:block}.center[data-v-45729730] .el-input-number--medium{width:150px}.footer[data-v-45729730]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;margin:0 100px 20px}

File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.1891a2bf.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.25ab9a4c.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-00246418.598a17cf.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-2e972bd4.e8dbfca8.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-52d27877.8490bad0.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-74c8073e.78b699c1.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-82c6794c.bddb9035.js


+ 45 - 23
src/components/FilePreview/index.vue

@@ -18,9 +18,13 @@
       />
 
       <!-- Word 文档预览 -->
-      <div v-if="isWord && wordLoaded" v-html="wordContent" class="word-preview"></div>
+      <div
+        v-if="isWord && wordLoaded"
+        v-html="wordContent"
+        class="word-preview"
+      ></div>
       <div v-else-if="isWord && !wordLoaded" class="loading-word">
-        {{ wordLoadingError ? '加载失败,请重试' : '加载中...' }}
+        {{ wordLoadingError ? "加载失败,请重试" : "加载中..." }}
       </div>
 
       <!-- 其他 Office 文档预览 -->
@@ -45,6 +49,7 @@
 </template>
   
   <script>
+  import { searchTaskInfo } from "@/api/knowledge";
 import mammoth from "mammoth";
 export default {
   props: {
@@ -77,12 +82,14 @@ export default {
       ],
       wordLoaded: false,
       wordLoadingError: false,
+      internalFileUrl: '', // 新增:内部使用的 URL
     };
   },
   watch: {
     fileUrl: {
       immediate: true,
-      handler() {
+      handler(newValue) {
+        /* this.internalFileUrl = newValue; */
         if (this.isWord) {
           this.loadWordContent();
         }
@@ -112,27 +119,42 @@ export default {
   },
   methods: {
     async loadWordContent() {
-      this.wordLoaded = false;
-      this.wordLoadingError = false;
-      this.fileUrl=localStorage.getItem('href')
-      try {
-        const response = await fetch(this.fileUrl);
-        if (!response.ok) {
-          throw new Error(`HTTP error! status: ${response.status}`);
-        }
-        const blob = await response.blob();
-        const arrayBuffer = await this.blobToArrayBuffer(blob);
-        const result = await mammoth.convertToHtml({ arrayBuffer });
-        this.wordContent = result.value;
-        this.wordLoaded = true;
-      } catch (error) {
-        console.error("加载Word文档内容时出错:", error);
-        this.wordContent = "无法加载Word文档内容";
-        this.wordLoadingError = true;
-      } finally {
-        this.wordLoaded = true;
+    this.wordLoaded = false;
+    this.wordLoadingError = false;
+    try {
+      // 获取文档 URL
+      const res = await searchTaskInfo({
+        page: 1,
+        page_size: 10,
+        document_id: this.$route.query.id,
+      });
+      this.internalFileUrl = res.data.documentUrl;
+
+      // 使用 fetch 获取文件内容,指定 responseType 为 'arraybuffer'
+      const response = await fetch(this.internalFileUrl, {
+        method: 'GET',
+        headers: {
+          'Content-Type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+        },
+      });
+
+      if (!response.ok) {
+        throw new Error(`HTTP error! status: ${response.status}`);
       }
-    },
+
+      const arrayBuffer = await response.arrayBuffer();
+      const result = await mammoth.convertToHtml({ arrayBuffer });
+      this.wordContent = result.value;
+      this.wordLoaded = true;
+    } catch (error) {
+      console.error("加载Word文档内容时出错:", error);
+      this.wordContent = `无法加载Word文档内容: ${error.message}`;
+      this.wordLoadingError = true;
+      this.$message.error(`文档加载失败: ${error.message}`);
+    } finally {
+      this.wordLoaded = true;
+    }
+  },
     blobToArrayBuffer(blob) {
       return new Promise((resolve, reject) => {
         const reader = new FileReader();

+ 1 - 1
src/components/ai.vue

@@ -313,7 +313,7 @@ export default {
           const result = await response.json();
           this.session_id = result.data.session_id;
           console.log(result.status);
-          if (result.status !== "success") {
+          if (result.code !== 200) {
             const errorText = await response.text(); // 获取错误文本
             throw new Error(
               `HTTP error! status: ${response.status}, message: ${errorText}`

+ 63 - 40
src/components/chartIcon/index.vue

@@ -1,46 +1,48 @@
 <template>
-    <div class="chat-icon" @click="toggleChat">
-      <i class="el-icon-chat-dot-round"></i>
-      <div v-if="showChat" class="chat-window">
-        <div class="chat-header">
-          <i class="el-icon-close close-icon" @click.stop="closeChat"></i>
-        </div>
-        <ChatBox />
+  <div class="chat-icon" @click="toggleChat">
+    <i class="el-icon-chat-dot-round animate-pulse"></i>
+    <div v-if="$store.state.app.showChat" class="chat-window">
+      <div class="chat-header">
+        <i class="el-icon-minus close-icon" @click.stop="closeChat"></i>
       </div>
+      <ChatBox />
     </div>
-  </template>
-  
-  <script>
-  import ChatBox from "@/components/ai.vue";
-  import LoginModal from "@/components/LoginModal";
-  import MarkdownIt from "markdown-it";
-  import { pcInnerAi, getMinioURl } from "@/api/api";
-  import { modelList, get_default } from "@/api/knowledge";
-  import axios from "axios";
-  const md = new MarkdownIt();
-  export default {
-    components: {
-     
-      ChatBox,
-    },
-    name: "ChatIcon",
-    data() {
-      return {
-        showChat: false,
-      };
+  </div>
+</template>
+
+<script>
+import ChatBox from "@/components/ai.vue";
+import LoginModal from "@/components/LoginModal";
+import MarkdownIt from "markdown-it";
+import { pcInnerAi, getMinioURl } from "@/api/api";
+import { modelList, get_default } from "@/api/knowledge";
+import axios from "axios";
+const md = new MarkdownIt();
+export default {
+  components: {
+   
+    ChatBox,
+  },
+  name: "ChatIcon",
+  data() {
+    return {
+      showChat: false,
+    };
+  },
+
+  methods: {
+    toggleChat() {
+      this.$store.state.app.showChat= true;
+      this.showChat = true;
     },
-  
-    methods: {
-      toggleChat() {
-        this.showChat = true;
-      },
-      closeChat() {
-        this.showChat = false;
-      },
+    closeChat() {
+      this.$store.state.app.showChat= false;
+      this.showChat = false;
     },
-  
-  };
-  </script>
+  },
+
+};
+</script>
   
   <style scoped>
   .chat-icon {
@@ -58,12 +60,27 @@
   .el-icon-chat-dot-round {
     color: white;
   }
+  @keyframes pulse {
+  0% {
+    transform: scale(1);
+  }
+  50% {
+    transform: scale(1.1);
+  }
+  100% {
+    transform: scale(1);
+  }
+}
+
+.animate-pulse {
+  animation: pulse 1.5s infinite ease-in-out;
+}
   .chat-window {
     position: absolute;
     bottom: 60px;
     right: 0;
     width: 500px;
-    height: 600px;
+    height: 625px;
     background-color: white;
     border: 1px solid #dcdfe6;
     border-radius: 4px;
@@ -108,11 +125,17 @@
   .chat-input {
     margin-top: 10px;
   }
+  ::v-deep .chat-container .content{
+    flex-direction: column;
+  }
   ::v-deep .messages{
-      height: calc(100vh - 515px);
+      height:445px; /* calc(100vh - 500px); */
   }
   ::v-deep .input-container{
+    margin: 0 auto;
+    position: unset;
       left: 50%;
+      transform: translateX(0%);
   }
   ::v-deep .sender-name{
       font-size: 14px;

+ 1 - 1
src/components/webAi/js/ChatBox.js

@@ -850,7 +850,7 @@ newChat() {
           const result = await response.json();
           this.session_id=result.data.session_id
           console.log(result.status);
-          if (result.status!=='success') {
+          if (result.code !== 200) {
             const errorText = await response.text(); // 获取错误文本
             throw new Error(
               `HTTP error! status: ${response.status}, message: ${errorText}`

+ 1 - 0
src/layout/components/Navbar.vue

@@ -82,6 +82,7 @@ export default {
   },
   methods: {
     openChatDialog() {
+      this.$store.state.app.showChat= true;
       this.chatDialogVisible = true;
       /* this.$router.push({
         path: "/knowledge/chatPage/index",

+ 8 - 1
src/store/modules/app.js

@@ -6,7 +6,8 @@ const state = {
     withoutAnimation: false
   },
   device: 'desktop',
-  size: Cookies.get('size') || 'small'
+  size: Cookies.get('size') || 'small',
+  showChat:false
 }
 
 const mutations = {
@@ -30,6 +31,9 @@ const mutations = {
   SET_SIZE: (state, size) => {
     state.size = size
     Cookies.set('size', size)
+  },
+  SET_showChat:(state,chat)=>{
+    console.log(state,chat);
   }
 }
 
@@ -45,6 +49,9 @@ const actions = {
   },
   setSize({ commit }, size) {
     commit('SET_SIZE', size)
+  },
+  showChat({ commit }, chat){
+    commit('SET_showChat', chat)
   }
 }
 

+ 1999 - 1906
src/views/appConfig/index.vue

@@ -1,1971 +1,2064 @@
 <template>
-    <div>
-      <div class="header">
-        <h2>
-          <span>{{
-            type == "add" ? "新增" : type == "edit" ? "编辑" : "查看"
-          }}</span
-          >应用
-        </h2>
-      </div>
-      <div class="center" v-if="type == 'add'">
-        <el-form
-          :inline="true"
-          :model="AIform"
-          :rules="rules"
-          ref="AIformRef"
-          class="demo-form-inline"
-          style="margin-top: 15px; margin-left: 50px"
-          label-position="top"
-          label-width="90px"
-        >
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="应用名称:" prop="chat_name">
-                <el-input
-                  style="width: 55%"
-                  v-model="AIform.chat_name"
-                  placeholder="请输入应用名称"
-                ></el-input>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="应用类型:" prop="application_type">
-                <el-select
-                  v-model="AIform.application_type"
-                  placeholder="应用类型"
-                  style="width: 55%"
-                  clearable
-                >
-                  <el-option
-                    v-for="(item, index) in appTypeList"
-                    :label="item.label"
-                    :value="item.value"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="模型名称:" prop="model_name">
-                <el-select
-                  v-model="AIform.model_name"
-                  placeholder="请输入选择"
-                  style="width: 55%"
-                  clearable
-                >
-                  <el-option
-                    v-for="(item, index) in modelNameList"
-                    :label="item.name"
-                    :value="item.name"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="知识库:" prop="knowledge_base_names">
-                <el-select
-                  v-model="AIform.knowledge_base_names"
-                  multiple
-                  placeholder="请选择知识库"
-                  style="width: 55%"
-                  @change="handleKnowledgeBaseChange"
-                  clearable
-                  filterable
-                >
-                  <el-option
-                    v-for="(item, index) in kneList"
-                    :label="item.name"
-                    :value="item.id"
-                    :key="index"
-                  ></el-option>
-                </el-select> </el-form-item
-            ></el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="文档目录:" prop="document_directories">
-                <el-select
-                  v-model="AIform.document_directories"
-                  placeholder="请选择文档目录"
-                  style="width: 55%"
-                  :disabled="!AIform.knowledge_base_names.length"
-                  @change="handleDirectoryChange"
-                  clearable
-                  filterable
-                >
-                  <el-option
-                    v-for="(dir, index) in directoryList"
-                    :label="dir.name"
-                    :value="dir.id"
-                    :key="index"
-                  ></el-option>
-                </el-select> </el-form-item
-            ></el-col>
-            <el-col :span="12">
-              <el-form-item label="文  档:" prop="documents">
-                <el-select
-                  v-model="AIform.documents"
-                  multiple
-                  placeholder="请选择文档"
-                  style="width: 55%"
-                  :disabled="isDocumentSelectDisabled"
-                  clearable
-                  filterable
-                >
-                  <el-option
-                    v-for="(doc, index) in documentList"
-                    :label="doc.name"
-                    :value="doc.id"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="描 述:">
-                <el-input
-                  style="width: 55%"
-                  v-model="AIform.role_description"
-                  placeholder="请输入描述"
-                  type="textarea"
-                ></el-input>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="温度:" prop="temperature">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="AIform.temperature"
-                    :min="0"
-                    :max="1"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="AIform.temperature"
-                    :min="0"
-                    :max="1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">控制生成文本的随机性,0为最保守,1为最创新</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="最大token数:" prop="max_tokens">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="AIform.max_tokens"
-                    :min="1"
-                    :max="4096"
-                    :step="1"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="AIform.max_tokens"
-                    :min="0"
-                    :max="4096"
-                    :step="1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">限制生成文本的最大长度</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="核采样参数:" prop="top_p">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="AIform.top_p"
-                    :min="0"
-                    :max="1"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="AIform.top_p"
-                    :min="0"
-                    :max="1"
-                    :step="0.1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">控制词汇多样性,1为考虑所有可能性</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="重复内容惩罚:" prop="frequency_penalty">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="AIform.frequency_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="AIform.frequency_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">防止重复,正值减少重复,负值增加重复</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="新话题偏好:" prop="presence_penalty">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="AIform.presence_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="AIform.presence_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">正值鼓励新话题,负值保持话题一致性</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="响应格式:" prop="response_format">
-                <el-input
-                  style="width: 55%"
-                  v-model="AIform.response_format"
-                  placeholder="text"
-                ></el-input>
-                <div class="hint">指定AI响应的格式,如text, json等</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-  
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="上下文窗口:" prop="context_window">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="AIform.context_window"
-                    :min="1"
-                    :max="4096"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="AIform.presence_penalty"
-                    :min="1"
-                    :max="4096"
-                    :step="1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">AI考虑的上下文token数量</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="会话ID:" prop="session_id">
-                <el-input
-                  style="width: 55%"
-                  v-model="AIform.session_id"
-                  placeholder="可选"
-                ></el-input>
-                <div class="hint">特定会话的唯一标识符,如果有的话</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="语言:" prop="language">
-                <el-select v-model="AIform.language" style="width: 55%">
-                  <el-option label="中文" value="zh"></el-option>
-                  <el-option label="English" value="en"></el-option>
-                  <el-option label="日本語" value="ja"></el-option>
-                  <el-option label="한국어" value="ko"></el-option>
-                  <el-option label="Français" value="fr"></el-option>
-                  <el-option label="Deutsch" value="de"></el-option>
-                </el-select>
-                <div class="hint">选择AI响应的主要语言</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="请求超时:" prop="timeout">
+  <div>
+    <div class="header">
+      <h2>
+        <span>{{
+          type == "add" ? "新增" : type == "edit" ? "编辑" : "查看"
+        }}</span
+        >应用
+      </h2>
+    </div>
+    <div class="center" v-if="type == 'add'">
+      <el-form
+        :inline="true"
+        :model="AIform"
+        :rules="rules"
+        ref="AIformRef"
+        class="demo-form-inline"
+        style="margin-top: 15px; margin-left: 50px"
+        label-position="top"
+        label-width="90px"
+      >
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="应用名称:" prop="chat_name">
+              <el-input
+                style="width: 55%"
+                v-model="AIform.chat_name"
+                placeholder="请输入应用名称"
+              ></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="应用类型:" prop="application_type">
+              <el-select
+                v-model="AIform.application_type"
+                placeholder="应用类型"
+                style="width: 55%"
+                clearable
+              >
+                <el-option
+                  v-for="(item, index) in appTypeList"
+                  :label="item.label"
+                  :value="item.value"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="模型名称:" prop="model_name">
+              <el-select
+                v-model="AIform.model_name"
+                placeholder="请输入选择"
+                style="width: 55%"
+                clearable
+              >
+                <el-option
+                  v-for="(item, index) in modelNameList"
+                  :label="item.name"
+                  :value="item.name"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="知识库:" prop="knowledge_base_names">
+              <el-select
+                v-model="AIform.knowledge_base_names"
+                multiple
+                placeholder="请选择知识库"
+                style="width: 55%"
+                @change="handleKnowledgeBaseChange"
+                clearable
+                filterable
+              >
+                <el-option
+                  v-for="(item, index) in kneList"
+                  :label="item.name"
+                  :value="item.id"
+                  :key="index"
+                ></el-option>
+              </el-select> </el-form-item
+          ></el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="文档目录:" prop="document_directories">
+              <el-select
+                v-model="AIform.document_directories"
+                placeholder="请选择文档目录"
+                style="width: 55%"
+                :disabled="!AIform.knowledge_base_names.length"
+                @change="handleDirectoryChange"
+                clearable
+                filterable
+              >
+                <el-option
+                  v-for="(dir, index) in directoryList"
+                  :label="dir.name"
+                  :value="dir.id"
+                  :key="index"
+                ></el-option>
+              </el-select> </el-form-item
+          ></el-col>
+          <el-col :span="12">
+            <el-form-item label="文  档:" prop="documents">
+              <el-select
+                v-model="AIform.documents"
+                multiple
+                placeholder="请选择文档"
+                style="width: 55%"
+                :disabled="isDocumentSelectDisabled"
+                clearable
+                filterable
+                @change="handleDocumentChange"
+              >
+                <el-option label="全部" value="all"></el-option>
+                <el-option
+                  v-for="(doc, index) in documentList"
+                  :label="doc.name"
+                  :value="doc.id"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="描 述:">
+              <el-input
+                style="width: 55%"
+                v-model="AIform.role_description"
+                placeholder="请输入描述"
+                type="textarea"
+              ></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="温度:" prop="temperature">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
+                  style="width: 60%"
+                  v-model="AIform.temperature"
+                  :min="0"
+                  :max="1"
+                  :step="0.1"
+                ></el-slider>
                 <el-input-number
-                  v-model="AIform.timeout"
+                  v-model="AIform.temperature"
+                  :min="0"
+                  :max="1"
+                ></el-input-number>
+              </div>
+              <div class="hint">控制生成文本的随机性,0为最保守,1为最创新</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="最大token数:" prop="max_tokens">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
+                  style="width: 60%"
+                  v-model="AIform.max_tokens"
                   :min="1"
-                  :max="60"
+                  :max="4096"
+                  :step="1"
+                ></el-slider>
+                <el-input-number
+                  v-model="AIform.max_tokens"
+                  :min="0"
+                  :max="4096"
+                  :step="1"
+                ></el-input-number>
+              </div>
+              <div class="hint">限制生成文本的最大长度</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="核采样参数:" prop="top_p">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
+                  style="width: 60%"
+                  v-model="AIform.top_p"
+                  :min="0"
+                  :max="1"
+                  :step="0.1"
+                ></el-slider>
+                <el-input-number
+                  v-model="AIform.top_p"
+                  :min="0"
+                  :max="1"
+                  :step="0.1"
                 ></el-input-number>
-                <div class="hint">设置请求的最大等待时间(秒)</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="角色名称:" prop="role_name">
-                <el-input
-                  style="width: 55%"
-                  v-model="AIform.role_name"
-                  placeholder="例如: 客服专员"
-                ></el-input>
-                <div class="hint">为AI助手设定一个角色名称</div>
-              </el-form-item>
-            </el-col>
-            <!--  <el-col :span="12">
-              <el-form-item label="角色描述:" prop="role_description">
-                <el-input
-                  style="width: 55%"
-                  v-model="AIform.role_description"
-                  type="textarea"
-                  :rows="3"
-                  placeholder="例如: 你是一位专业的客服专员,负责解答客户关于我们产品和服务的问题。"
-                ></el-input>
-                <div class="hint">详细描述AI助手的角色和职责</div>
-              </el-form-item>
-            </el-col> -->
-            <el-col :span="12">
-              <el-form-item label="角色权限:" prop="role_permissions">
-                <el-input
-                  style="width: 55%"
-                  v-model="AIform.role_permissions"
-                  placeholder='["回答产品问题", "处理退换货请求", "升级复杂问题"]'
-                ></el-input>
-                <div class="hint">输入JSON数组,列出AI助手的具体权限</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-  
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="自定义变量:" prop="custom_variables">
-                <el-input
-                  style="width: 55%"
-                  v-model="AIform.custom_variables"
-                  placeholder='{"custom_greeting": "很高兴为您服务!", "company_name": "ABC公司"}'
-                ></el-input>
-                <div class="hint">
-                  输入JSON对象,定义可在提示模板中使用的自定义变量
-                </div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="自定义提示模板:" prop="custom_prompt">
-                <el-input
+              </div>
+              <div class="hint">控制词汇多样性,1为考虑所有可能性</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="重复内容惩罚:" prop="frequency_penalty">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
                   style="width: 60%"
-                  v-model="AIform.custom_prompt"
-                  type="textarea"
-                  :rows="6"
-                  placeholder="使用以下上下文来回答问题。如果你不知道答案,就说你不知道,不要试图编造答案。
-                      上下文: {context}
-                      人类: {question}
-                      AI助手: 让我根据提供的上下文来回答你的问题。{custom_greeting}"
-                ></el-input>
-                <div class="hint">
-                  自定义AI助手的回答模板,可使用变量如{context}, {question}等
-                </div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-  
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="是否启用API_key:" prop="generate_new_api_key">
-                <el-switch
-                  v-model="AIform.generate_new_api_key"
-                  active-color="#13ce66"
-                  inactive-color="#ff4949"
-                >
-                </el-switch>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="是否设为默认:" prop="is_default">
-                <el-switch
-                  v-model="AIform.is_default"
-                  active-color="#13ce66"
-                  inactive-color="#ff4949"
-                >
-                </el-switch>
-              </el-form-item>
-            </el-col>
-          </el-row>
-        </el-form>
-      </div>
-      <div class="center" v-else-if="type == 'edit'">
-        <el-form
-          :model="editForm"
-          :rules="rules"
-          ref="editFormRef"
-          label-width="120px"
-          style="margin: 20px 50px"
-          label-position="top"
-        >
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="应用名称:" prop="chat_name">
-                <el-input
-                  style="width: 55%"
-                  v-model="editForm.chat_name"
-                  placeholder="请输入应用名称"
-                ></el-input>
-              </el-form-item>
-              <!-- <el-form-item label="模型库:" prop="modelLibrary">
-                <el-select
-                  v-model="editForm.modelLibrary"
-                  placeholder="ollama"
-                  style="width: 100%"
-                >
-                  <el-option label="ollama" value="ollama"></el-option>
-                </el-select>
-              </el-form-item> -->
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="应用类型:" prop="application_type">
-                <el-select
-                  v-model="editForm.application_type"
-                  placeholder="应用类型"
-                  style="width: 55%"
-                  clearable
-                >
-                  <el-option
-                    v-for="(item, index) in appTypeList"
-                    :label="item.label"
-                    :value="item.value"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="模型名称:" prop="model_name">
-                <el-select
-                  v-model="editForm.model_name"
-                  placeholder="请输入选择"
-                  style="width: 55%"
-                  clearable
-                >
-                  <el-option
-                    v-for="(item, index) in modelNameList"
-                    :label="item.name"
-                    :value="item.name"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-              <!-- <el-form-item label="模型类型:" prop="model_type">
-                <el-select
-                  v-model="editForm.model_type"
-                  placeholder="请输入选择"
-                  style="width: 100%"
-                >
-                  <el-option label="chat" value="chat"></el-option>
-                </el-select>
-              </el-form-item> -->
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="知识库:" prop="knowledge_base_names">
-                <el-select
-                  v-model="editForm.knowledge_base_names"
-                  multiple
-                  placeholder="请选择知识库"
-                  style="width: 55%"
-                  @change="handleEditKnowledgeBaseChange"
-                  clearable
-                  filterable
-                >
-                  <el-option
-                    v-for="(item, index) in kneList"
-                    :label="item.name"
-                    :value="item.id"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="文档目录:" prop="document_directories">
-                <el-select
-                  v-model="editForm.document_directories"
-                  placeholder="请选择文档目录"
-                  style="width: 55%"
-                  :disabled="
-                    !(
-                      editForm.knowledge_base_names &&
-                      editForm.knowledge_base_names.length
-                    )
-                  "
-                  @change="handleEditDirectoryChange"
-                  clearable
-                  filterable
-                >
-                  <el-option
-                    v-for="(dir, index) in editDirectoryList"
-                    :label="dir.name"
-                    :value="dir.id"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="文  档:" prop="documents">
-                <el-select
-                  v-model="editForm.documents"
-                  multiple
-                  placeholder="请选择文档"
-                  style="width: 55%"
-                  :disabled="editForm.document_directories == ''"
-                  clearable
-                  filterable
-                >
-                  <el-option
-                    v-for="(doc, index) in editDocumentList"
-                    :label="doc.name"
-                    :value="doc.id"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="描 述:">
-                <el-input
-                  style="width: 55%"
-                  v-model="editForm.role_description"
-                  placeholder="请输入描述"
-                  type="textarea"
-                ></el-input>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="温度:" prop="temperature">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="editForm.temperature"
-                    :min="0"
-                    :max="1"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="editForm.temperature"
-                    :min="0"
-                    :max="1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">控制生成文本的随机性,0为最保守,1为最创新</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="最大token数:" prop="max_tokens">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="editForm.max_tokens"
-                    :min="1"
-                    :max="4096"
-                    :step="1"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="editForm.max_tokens"
-                    :min="0"
-                    :max="4096"
-                    :step="1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">限制生成文本的最大长度</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="核采样参数:" prop="top_p">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="editForm.top_p"
-                    :min="0"
-                    :max="1"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="editForm.top_p"
-                    :min="0"
-                    :max="1"
-                    :step="0.1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">控制词汇多样性,1为考虑所有可能性</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="重复内容惩罚:" prop="frequency_penalty">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="editForm.frequency_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="editForm.frequency_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">防止重复,正值减少重复,负值增加重复</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="新话题偏好:" prop="presence_penalty">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="editForm.presence_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="editForm.presence_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">正值鼓励新话题,负值保持话题一致性</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="响应格式:" prop="response_format">
-                <el-input
-                  style="width: 55%"
-                  v-model="editForm.response_format"
-                  placeholder="text"
-                ></el-input>
-                <div class="hint">指定AI响应的格式,如text, json等</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-  
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="上下文窗口:" prop="context_window">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    style="width: 60%"
-                    v-model="editForm.context_window"
-                    :min="1"
-                    :max="4096"
-                  ></el-slider>
-                  <el-input-number
-                    v-model="editForm.presence_penalty"
-                    :min="1"
-                    :max="4096"
-                    :step="1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">AI考虑的上下文token数量</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="会话ID:" prop="session_id">
-                <el-input
-                  style="width: 55%"
-                  v-model="editForm.session_id"
-                  placeholder="可选"
-                ></el-input>
-                <div class="hint">特定会话的唯一标识符,如果有的话</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="语言:" prop="language">
-                <el-select v-model="editForm.language" style="width: 55%">
-                  <el-option label="中文" value="zh"></el-option>
-                  <el-option label="English" value="en"></el-option>
-                  <el-option label="日本語" value="ja"></el-option>
-                  <el-option label="한국어" value="ko"></el-option>
-                  <el-option label="Français" value="fr"></el-option>
-                  <el-option label="Deutsch" value="de"></el-option>
-                </el-select>
-                <div class="hint">选择AI响应的主要语言</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="请求超时:" prop="timeout">
+                  v-model="AIform.frequency_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-slider>
+                <el-input-number
+                  v-model="AIform.frequency_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-input-number>
+              </div>
+              <div class="hint">防止重复,正值减少重复,负值增加重复</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="新话题偏好:" prop="presence_penalty">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
+                  style="width: 60%"
+                  v-model="AIform.presence_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-slider>
+                <el-input-number
+                  v-model="AIform.presence_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-input-number>
+              </div>
+              <div class="hint">正值鼓励新话题,负值保持话题一致性</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="响应格式:" prop="response_format">
+              <el-input
+                style="width: 55%"
+                v-model="AIform.response_format"
+                placeholder="text"
+              ></el-input>
+              <div class="hint">指定AI响应的格式,如text, json等</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="上下文窗口:" prop="context_window">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
+                  style="width: 60%"
+                  v-model="AIform.context_window"
+                  :min="1"
+                  :max="4096"
+                ></el-slider>
                 <el-input-number
-                  v-model="editForm.timeout"
+                  v-model="AIform.presence_penalty"
                   :min="1"
-                  :max="60"
+                  :max="4096"
+                  :step="1"
                 ></el-input-number>
-                <div class="hint">设置请求的最大等待时间(秒)</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="角色名称:" prop="role_name">
-                <el-input
-                  style="width: 55%"
-                  v-model="editForm.role_name"
-                  placeholder="例如: 客服专员"
-                ></el-input>
-                <div class="hint">为AI助手设定一个角色名称</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="角色权限:" prop="role_permissions">
-                <el-input
-                  style="width: 55%"
-                  v-model="editForm.role_permissions"
-                  placeholder='["回答产品问题", "处理退换货请求", "升级复杂问题"]'
-                ></el-input>
-                <div class="hint">输入JSON数组,列出AI助手的具体权限</div>
-              </el-form-item>
-            </el-col>
-            <!-- <el-col :span="12">
-              <el-form-item label="角色描述:" prop="role_description">
-                <el-input
-                 style="width: 55%"
-                  v-model="editForm.role_description"
-                  type="textarea"
-                  :rows="3"
-                  placeholder="例如: 你是一位专业的客服专员,负责解答客户关于我们产品和服务的问题。"
-                ></el-input>
-                <div class="hint">详细描述AI助手的角色和职责</div>
-              </el-form-item>
-            </el-col> -->
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="自定义变量:" prop="custom_variables">
-                <el-input
-                  style="width: 55%"
-                  v-model="editForm.custom_variables"
-                  placeholder='{"custom_greeting": "很高兴为您服务!", "company_name": "ABC公司"}'
-                ></el-input>
-                <div class="hint">
-                  输入JSON对象,定义可在提示模板中使用的自定义变量
-                </div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="自定义提示模板:" prop="custom_prompt">
-                <el-input
+              </div>
+              <div class="hint">AI考虑的上下文token数量</div>
+            </el-form-item>
+          </el-col>
+          <!-- <el-col :span="12">
+            <el-form-item label="会话ID:" prop="session_id">
+              <el-input
+                style="width: 55%"
+                v-model="AIform.session_id"
+                placeholder="可选"
+              ></el-input>
+              <div class="hint">特定会话的唯一标识符,如果有的话</div>
+            </el-form-item>
+          </el-col> -->
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="语言:" prop="language">
+              <el-select v-model="AIform.language" style="width: 55%">
+                <el-option label="中文" value="zh"></el-option>
+                <el-option label="English" value="en"></el-option>
+                <el-option label="日本語" value="ja"></el-option>
+                <el-option label="한국어" value="ko"></el-option>
+                <el-option label="Français" value="fr"></el-option>
+                <el-option label="Deutsch" value="de"></el-option>
+              </el-select>
+              <div class="hint">选择AI响应的主要语言</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="请求超时:" prop="timeout">
+              <el-input-number
+                v-model="AIform.timeout"
+                :min="1"
+                :max="60"
+              ></el-input-number>
+              <div class="hint">设置请求的最大等待时间(秒)</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="角色名称:" prop="role_name">
+              <el-input
+                style="width: 55%"
+                v-model="AIform.role_name"
+                placeholder="例如: 客服专员"
+              ></el-input>
+              <div class="hint">为AI助手设定一个角色名称</div>
+            </el-form-item>
+          </el-col>
+          <!--  <el-col :span="12">
+            <el-form-item label="角色描述:" prop="role_description">
+              <el-input
+                style="width: 55%"
+                v-model="AIform.role_description"
+                type="textarea"
+                :rows="3"
+                placeholder="例如: 你是一位专业的客服专员,负责解答客户关于我们产品和服务的问题。"
+              ></el-input>
+              <div class="hint">详细描述AI助手的角色和职责</div>
+            </el-form-item>
+          </el-col> -->
+          <el-col :span="12">
+            <el-form-item label="角色权限:" prop="role_permissions">
+              <el-input
+                style="width: 55%"
+                v-model="AIform.role_permissions"
+                placeholder='["回答产品问题", "处理退换货请求", "升级复杂问题"]'
+              ></el-input>
+              <div class="hint">输入JSON数组,列出AI助手的具体权限</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="自定义变量:" prop="custom_variables">
+              <el-input
+                style="width: 55%"
+                v-model="AIform.custom_variables"
+                placeholder='{"custom_greeting": "很高兴为您服务!", "company_name": "ABC公司"}'
+              ></el-input>
+              <div class="hint">
+                输入JSON对象,定义可在提示模板中使用的自定义变量
+              </div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="自定义提示模板:" prop="custom_prompt">
+              <el-input
+                style="width: 60%"
+                v-model="AIform.custom_prompt"
+                type="textarea"
+                :rows="6"
+                placeholder="使用以下上下文来回答问题。如果你不知道答案,就说你不知道,不要试图编造答案。
+                    上下文: {context}
+                    人类: {question}
+                    AI助手: 让我根据提供的上下文来回答你的问题。{custom_greeting}"
+              ></el-input>
+              <div class="hint">
+                自定义AI助手的回答模板,可使用变量如{context}, {question}等
+              </div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="是否启用API_key:" prop="generate_new_api_key">
+              <el-switch
+                v-model="AIform.generate_new_api_key"
+                active-color="#13ce66"
+                inactive-color="#ff4949"
+              >
+              </el-switch>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="是否设为默认:" prop="is_default">
+              <el-switch
+                v-model="AIform.is_default"
+                active-color="#13ce66"
+                inactive-color="#ff4949"
+              >
+              </el-switch>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+    </div>
+    <div class="center" v-else-if="type == 'edit'">
+      <el-form
+        :model="editForm"
+        :rules="rules"
+        ref="editFormRef"
+        label-width="120px"
+        style="margin: 20px 50px"
+        label-position="top"
+      >
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="应用名称:" prop="chat_name">
+              <el-input
+                style="width: 55%"
+                v-model="editForm.chat_name"
+                placeholder="请输入应用名称"
+              ></el-input>
+            </el-form-item>
+            <!-- <el-form-item label="模型库:" prop="modelLibrary">
+              <el-select
+                v-model="editForm.modelLibrary"
+                placeholder="ollama"
+                style="width: 100%"
+              >
+                <el-option label="ollama" value="ollama"></el-option>
+              </el-select>
+            </el-form-item> -->
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="应用类型:" prop="application_type">
+              <el-select
+                v-model="editForm.application_type"
+                placeholder="应用类型"
+                style="width: 55%"
+                clearable
+              >
+                <el-option
+                  v-for="(item, index) in appTypeList"
+                  :label="item.label"
+                  :value="item.value"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="模型名称:" prop="model_name">
+              <el-select
+                v-model="editForm.model_name"
+                placeholder="请输入选择"
+                style="width: 55%"
+                clearable
+              >
+                <el-option
+                  v-for="(item, index) in modelNameList"
+                  :label="item.name"
+                  :value="item.name"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+            <!-- <el-form-item label="模型类型:" prop="model_type">
+              <el-select
+                v-model="editForm.model_type"
+                placeholder="请输入选择"
+                style="width: 100%"
+              >
+                <el-option label="chat" value="chat"></el-option>
+              </el-select>
+            </el-form-item> -->
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="知识库:" prop="knowledge_base_names">
+              <el-select
+                v-model="editForm.knowledge_base_names"
+                multiple
+                placeholder="请选择知识库"
+                style="width: 55%"
+                @change="handleEditKnowledgeBaseChange"
+                clearable
+                filterable
+              >
+                <el-option
+                  v-for="(item, index) in kneList"
+                  :label="item.name"
+                  :value="item.id"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="文档目录:" prop="document_directories">
+              <el-select
+                v-model="editForm.document_directories"
+                placeholder="请选择文档目录"
+                style="width: 55%"
+                :disabled="
+                  !(
+                    editForm.knowledge_base_names &&
+                    editForm.knowledge_base_names.length
+                  )
+                "
+                @change="handleEditDirectoryChange"
+                clearable
+                filterable
+              >
+                <el-option
+                  v-for="(dir, index) in editDirectoryList"
+                  :label="dir.name"
+                  :value="dir.id"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="文  档:" prop="documents">
+              <el-select
+                v-model="editForm.documents"
+                multiple
+                placeholder="请选择文档"
+                style="width: 55%"
+                :disabled="editForm.document_directories == ''"
+                clearable
+                filterable
+                @change="handleEditDocumentChange"
+              >
+                <el-option label="全部" value="all"></el-option>
+                <el-option
+                  v-for="(doc, index) in editDocumentList"
+                  :label="doc.name"
+                  :value="doc.id"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="描 述:">
+              <el-input
+                style="width: 55%"
+                v-model="editForm.role_description"
+                placeholder="请输入描述"
+                type="textarea"
+              ></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="温度:" prop="temperature">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
                   style="width: 60%"
-                  v-model="editForm.custom_prompt"
-                  type="textarea"
-                  :rows="6"
-                  placeholder="使用以下上下文来回答问题。如果你不知道答案,就说你不知道,不要试图编造答案。
-                      上下文: {context}
-                      人类: {question}
-                      AI助手: 让我根据提供的上下文来回答你的问题。{custom_greeting}"
-                ></el-input>
-                <div class="hint">
-                  自定义AI助手的回答模板,可使用变量如{context}, {question}等
-                </div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="是否启用API_key:" prop="generate_new_api_key">
-                <el-switch
-                  v-model="editForm.generate_new_api_key"
-                  active-color="#13ce66"
-                  inactive-color="#ff4949"
-                >
-                </el-switch>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="是否设为默认:" prop="is_default">
-                <el-switch
-                  v-model="editForm.is_default"
-                  active-color="#13ce66"
-                  inactive-color="#ff4949"
-                >
-                </el-switch>
-              </el-form-item>
-            </el-col>
-          </el-row>
-        </el-form>
-      </div>
-      <div class="center" v-else>
-        <el-form
-          :model="viewForm"
-          :rules="rules"
-          ref="viewFormRef"
-          label-width="120px"
-          style="margin: 20px 50px"
-          label-position="top"
-        >
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="应用名称:" prop="chat_name">
-                <el-input
-                  disabled
-                  style="width: 55%"
-                  v-model="viewForm.chat_name"
-                  placeholder="请输入应用名称"
-                ></el-input>
-              </el-form-item>
-              <!-- <el-form-item label="模型库:" prop="modelLibrary">
-                <el-select
-                  v-model="viewForm.modelLibrary"
-                  placeholder="ollama"
-                  style="width: 100%"
-                >
-                  <el-option label="ollama" value="ollama"></el-option>
-                </el-select>
-              </el-form-item> -->
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="应用类型:" prop="application_type">
-                <el-select
-                  disabled
-                  v-model="viewForm.application_type"
-                  placeholder="应用类型"
-                  style="width: 55%"
-                  clearable
-                >
-                  <el-option
-                    v-for="(item, index) in appTypeList"
-                    :label="item.label"
-                    :value="item.value"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="模型名称:" prop="model_name">
-                <el-select
-                  disabled
-                  v-model="viewForm.model_name"
-                  placeholder="请输入选择"
-                  style="width: 55%"
-                  clearable
-                >
-                  <el-option
-                    v-for="(item, index) in modelNameList"
-                    :label="item.name"
-                    :value="item.name"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-              <!-- <el-form-item label="模型类型:" prop="model_type">
-                <el-select
-                  v-model="viewForm.model_type"
-                  placeholder="请输入选择"
-                  style="width: 100%"
-                >
-                  <el-option label="chat" value="chat"></el-option>
-                </el-select>
-              </el-form-item> -->
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="知识库:" prop="knowledge_base_names">
-                <el-select
+                  v-model="editForm.temperature"
+                  :min="0"
+                  :max="1"
+                  :step="0.1"
+                ></el-slider>
+                <el-input-number
+                  v-model="editForm.temperature"
+                  :min="0"
+                  :max="1"
+                ></el-input-number>
+              </div>
+              <div class="hint">控制生成文本的随机性,0为最保守,1为最创新</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="最大token数:" prop="max_tokens">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
+                  style="width: 60%"
+                  v-model="editForm.max_tokens"
+                  :min="1"
+                  :max="4096"
+                  :step="1"
+                ></el-slider>
+                <el-input-number
+                  v-model="editForm.max_tokens"
+                  :min="0"
+                  :max="4096"
+                  :step="1"
+                ></el-input-number>
+              </div>
+              <div class="hint">限制生成文本的最大长度</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="核采样参数:" prop="top_p">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
+                  style="width: 60%"
+                  v-model="editForm.top_p"
+                  :min="0"
+                  :max="1"
+                  :step="0.1"
+                ></el-slider>
+                <el-input-number
+                  v-model="editForm.top_p"
+                  :min="0"
+                  :max="1"
+                  :step="0.1"
+                ></el-input-number>
+              </div>
+              <div class="hint">控制词汇多样性,1为考虑所有可能性</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="重复内容惩罚:" prop="frequency_penalty">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
+                  style="width: 60%"
+                  v-model="editForm.frequency_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-slider>
+                <el-input-number
+                  v-model="editForm.frequency_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-input-number>
+              </div>
+              <div class="hint">防止重复,正值减少重复,负值增加重复</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="新话题偏好:" prop="presence_penalty">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
+                  style="width: 60%"
+                  v-model="editForm.presence_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-slider>
+                <el-input-number
+                  v-model="editForm.presence_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-input-number>
+              </div>
+              <div class="hint">正值鼓励新话题,负值保持话题一致性</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="响应格式:" prop="response_format">
+              <el-input
+                style="width: 55%"
+                v-model="editForm.response_format"
+                placeholder="text"
+              ></el-input>
+              <div class="hint">指定AI响应的格式,如text, json等</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="上下文窗口:" prop="context_window">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
+                  style="width: 60%"
+                  v-model="editForm.context_window"
+                  :min="1"
+                  :max="4096"
+                ></el-slider>
+                <el-input-number
+                  v-model="editForm.presence_penalty"
+                  :min="1"
+                  :max="4096"
+                  :step="1"
+                ></el-input-number>
+              </div>
+              <div class="hint">AI考虑的上下文token数量</div>
+            </el-form-item>
+          </el-col>
+          <!-- <el-col :span="12">
+            <el-form-item label="会话ID:" prop="session_id">
+              <el-input
+                style="width: 55%"
+                v-model="editForm.session_id"
+                placeholder="可选"
+              ></el-input>
+              <div class="hint">特定会话的唯一标识符,如果有的话</div>
+            </el-form-item>
+          </el-col> -->
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="语言:" prop="language">
+              <el-select v-model="editForm.language" style="width: 55%">
+                <el-option label="中文" value="zh"></el-option>
+                <el-option label="English" value="en"></el-option>
+                <el-option label="日本語" value="ja"></el-option>
+                <el-option label="한국어" value="ko"></el-option>
+                <el-option label="Français" value="fr"></el-option>
+                <el-option label="Deutsch" value="de"></el-option>
+              </el-select>
+              <div class="hint">选择AI响应的主要语言</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="请求超时:" prop="timeout">
+              <el-input-number
+                v-model="editForm.timeout"
+                :min="1"
+                :max="60"
+              ></el-input-number>
+              <div class="hint">设置请求的最大等待时间(秒)</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="角色名称:" prop="role_name">
+              <el-input
+                style="width: 55%"
+                v-model="editForm.role_name"
+                placeholder="例如: 客服专员"
+              ></el-input>
+              <div class="hint">为AI助手设定一个角色名称</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="角色权限:" prop="role_permissions">
+              <el-input
+                style="width: 55%"
+                v-model="editForm.role_permissions"
+                placeholder='["回答产品问题", "处理退换货请求", "升级复杂问题"]'
+              ></el-input>
+              <div class="hint">输入JSON数组,列出AI助手的具体权限</div>
+            </el-form-item>
+          </el-col>
+          <!-- <el-col :span="12">
+            <el-form-item label="角色描述:" prop="role_description">
+              <el-input
+               style="width: 55%"
+                v-model="editForm.role_description"
+                type="textarea"
+                :rows="3"
+                placeholder="例如: 你是一位专业的客服专员,负责解答客户关于我们产品和服务的问题。"
+              ></el-input>
+              <div class="hint">详细描述AI助手的角色和职责</div>
+            </el-form-item>
+          </el-col> -->
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="自定义变量:" prop="custom_variables">
+              <el-input
+                style="width: 55%"
+                v-model="editForm.custom_variables"
+                placeholder='{"custom_greeting": "很高兴为您服务!", "company_name": "ABC公司"}'
+              ></el-input>
+              <div class="hint">
+                输入JSON对象,定义可在提示模板中使用的自定义变量
+              </div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="自定义提示模板:" prop="custom_prompt">
+              <el-input
+                style="width: 60%"
+                v-model="editForm.custom_prompt"
+                type="textarea"
+                :rows="6"
+                placeholder="使用以下上下文来回答问题。如果你不知道答案,就说你不知道,不要试图编造答案。
+                    上下文: {context}
+                    人类: {question}
+                    AI助手: 让我根据提供的上下文来回答你的问题。{custom_greeting}"
+              ></el-input>
+              <div class="hint">
+                自定义AI助手的回答模板,可使用变量如{context}, {question}等
+              </div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="是否启用API_key:" prop="generate_new_api_key">
+              <el-switch
+                v-model="editForm.generate_new_api_key"
+                active-color="#13ce66"
+                inactive-color="#ff4949"
+              >
+              </el-switch>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="是否设为默认:" prop="is_default">
+              <el-switch
+                v-model="editForm.is_default"
+                active-color="#13ce66"
+                inactive-color="#ff4949"
+              >
+              </el-switch>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+    </div>
+    <div class="center" v-else>
+      <el-form
+        :model="viewForm"
+        :rules="rules"
+        ref="viewFormRef"
+        label-width="120px"
+        style="margin: 20px 50px"
+        label-position="top"
+      >
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="应用名称:" prop="chat_name">
+              <el-input
+                disabled
+                style="width: 55%"
+                v-model="viewForm.chat_name"
+                placeholder="请输入应用名称"
+              ></el-input>
+            </el-form-item>
+            <!-- <el-form-item label="模型库:" prop="modelLibrary">
+              <el-select
+                v-model="viewForm.modelLibrary"
+                placeholder="ollama"
+                style="width: 100%"
+              >
+                <el-option label="ollama" value="ollama"></el-option>
+              </el-select>
+            </el-form-item> -->
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="应用类型:" prop="application_type">
+              <el-select
+                disabled
+                v-model="viewForm.application_type"
+                placeholder="应用类型"
+                style="width: 55%"
+                clearable
+              >
+                <el-option
+                  v-for="(item, index) in appTypeList"
+                  :label="item.label"
+                  :value="item.value"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="模型名称:" prop="model_name">
+              <el-select
+                disabled
+                v-model="viewForm.model_name"
+                placeholder="请输入选择"
+                style="width: 55%"
+                clearable
+              >
+                <el-option
+                  v-for="(item, index) in modelNameList"
+                  :label="item.name"
+                  :value="item.name"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+            <!-- <el-form-item label="模型类型:" prop="model_type">
+              <el-select
+                v-model="viewForm.model_type"
+                placeholder="请输入选择"
+                style="width: 100%"
+              >
+                <el-option label="chat" value="chat"></el-option>
+              </el-select>
+            </el-form-item> -->
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="知识库:" prop="knowledge_base_names">
+              <el-select
+                disabled
+                v-model="viewForm.knowledge_base_names"
+                multiple
+                placeholder="请选择知识库"
+                style="width: 55%"
+                @change="handleEditKnowledgeBaseChange"
+                clearable
+                filterable
+              >
+                <el-option
+                  v-for="(item, index) in kneList"
+                  :label="item.name"
+                  :value="item.id"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="文档目录:" prop="document_directories">
+              <el-select
+                v-model="viewForm.document_directories"
+                placeholder="请选择文档目录"
+                style="width: 55%"
+                disabled
+                @change="handleEditDirectoryChange"
+                clearable
+                filterable
+              >
+                <el-option
+                  v-for="(dir, index) in editDirectoryList"
+                  :label="dir.name"
+                  :value="dir.id"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="文  档:" prop="documents">
+              <el-select
+                v-model="viewForm.documents"
+                multiple
+                placeholder="请选择文档"
+                style="width: 55%"
+                disabled
+                clearable
+                filterable
+              >
+                <el-option
+                  v-for="(doc, index) in editDocumentList"
+                  :label="doc.name"
+                  :value="doc.id"
+                  :key="index"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="描 述:">
+              <el-input
+                disabled
+                style="width: 55%"
+                v-model="viewForm.role_description"
+                placeholder="请输入描述"
+                type="textarea"
+              ></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="温度:" prop="temperature">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
                   disabled
-                  v-model="viewForm.knowledge_base_names"
-                  multiple
-                  placeholder="请选择知识库"
-                  style="width: 55%"
-                  @change="handleEditKnowledgeBaseChange"
-                  clearable
-                  filterable
-                >
-                  <el-option
-                    v-for="(item, index) in kneList"
-                    :label="item.name"
-                    :value="item.id"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="文档目录:" prop="document_directories">
-                <el-select
-                  v-model="viewForm.document_directories"
-                  placeholder="请选择文档目录"
-                  style="width: 55%"
+                  style="width: 60%"
+                  v-model="viewForm.temperature"
+                  :min="0"
+                  :max="1"
+                  :step="0.1"
+                ></el-slider>
+                <el-input-number
                   disabled
-                  @change="handleEditDirectoryChange"
-                  clearable
-                  filterable
-                >
-                  <el-option
-                    v-for="(dir, index) in editDirectoryList"
-                    :label="dir.name"
-                    :value="dir.id"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="文  档:" prop="documents">
-                <el-select
-                  v-model="viewForm.documents"
-                  multiple
-                  placeholder="请选择文档"
-                  style="width: 55%"
+                  v-model="viewForm.temperature"
+                  :min="0"
+                  :max="1"
+                ></el-input-number>
+              </div>
+              <div class="hint">控制生成文本的随机性,0为最保守,1为最创新</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="最大token数:" prop="max_tokens">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
                   disabled
-                  clearable
-                  filterable
-                >
-                  <el-option
-                    v-for="(doc, index) in editDocumentList"
-                    :label="doc.name"
-                    :value="doc.id"
-                    :key="index"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="描 述:">
-                <el-input
+                  style="width: 60%"
+                  v-model="viewForm.max_tokens"
+                  :min="1"
+                  :max="4096"
+                  :step="1"
+                ></el-slider>
+                <el-input-number
                   disabled
-                  style="width: 55%"
-                  v-model="viewForm.role_description"
-                  placeholder="请输入描述"
-                  type="textarea"
-                ></el-input>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="温度:" prop="temperature">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    disabled
-                    style="width: 60%"
-                    v-model="viewForm.temperature"
-                    :min="0"
-                    :max="1"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    disabled
-                    v-model="viewForm.temperature"
-                    :min="0"
-                    :max="1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">控制生成文本的随机性,0为最保守,1为最创新</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="最大token数:" prop="max_tokens">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    disabled
-                    style="width: 60%"
-                    v-model="viewForm.max_tokens"
-                    :min="1"
-                    :max="4096"
-                    :step="1"
-                  ></el-slider>
-                  <el-input-number
-                    disabled
-                    v-model="viewForm.max_tokens"
-                    :min="0"
-                    :max="4096"
-                    :step="1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">限制生成文本的最大长度</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="核采样参数:" prop="top_p">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    disabled
-                    style="width: 60%"
-                    v-model="viewForm.top_p"
-                    :min="0"
-                    :max="1"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    disabled
-                    v-model="viewForm.top_p"
-                    :min="0"
-                    :max="1"
-                    :step="0.1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">控制词汇多样性,1为考虑所有可能性</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="重复内容惩罚:" prop="frequency_penalty">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    disabled
-                    style="width: 60%"
-                    v-model="viewForm.frequency_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    disabled
-                    v-model="viewForm.frequency_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">防止重复,正值减少重复,负值增加重复</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="新话题偏好:" prop="presence_penalty">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    disabled
-                    style="width: 60%"
-                    v-model="viewForm.presence_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-slider>
-                  <el-input-number
-                    disabled
-                    v-model="viewForm.presence_penalty"
-                    :min="-2"
-                    :max="2"
-                    :step="0.1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">正值鼓励新话题,负值保持话题一致性</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="响应格式:" prop="response_format">
-                <el-input
+                  v-model="viewForm.max_tokens"
+                  :min="0"
+                  :max="4096"
+                  :step="1"
+                ></el-input-number>
+              </div>
+              <div class="hint">限制生成文本的最大长度</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="核采样参数:" prop="top_p">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
                   disabled
-                  style="width: 55%"
-                  v-model="viewForm.response_format"
-                  placeholder="text"
-                ></el-input>
-                <div class="hint">指定AI响应的格式,如text, json等</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-  
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="上下文窗口:" prop="context_window">
-                <div style="display: flex; justify-content: space-around">
-                  <el-slider
-                    disabled
-                    style="width: 60%"
-                    v-model="viewForm.context_window"
-                    :min="1"
-                    :max="4096"
-                  ></el-slider>
-                  <el-input-number
-                    disabled
-                    v-model="viewForm.presence_penalty"
-                    :min="1"
-                    :max="4096"
-                    :step="1"
-                  ></el-input-number>
-                </div>
-                <div class="hint">AI考虑的上下文token数量</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="会话ID:" prop="session_id">
-                <el-input
+                  style="width: 60%"
+                  v-model="viewForm.top_p"
+                  :min="0"
+                  :max="1"
+                  :step="0.1"
+                ></el-slider>
+                <el-input-number
                   disabled
-                  style="width: 55%"
-                  v-model="viewForm.session_id"
-                  placeholder="可选"
-                ></el-input>
-                <div class="hint">特定会话的唯一标识符,如果有的话</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="语言:" prop="language">
-                <el-select
+                  v-model="viewForm.top_p"
+                  :min="0"
+                  :max="1"
+                  :step="0.1"
+                ></el-input-number>
+              </div>
+              <div class="hint">控制词汇多样性,1为考虑所有可能性</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="重复内容惩罚:" prop="frequency_penalty">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
                   disabled
-                  v-model="viewForm.language"
-                  style="width: 55%"
-                >
-                  <el-option label="中文" value="zh"></el-option>
-                  <el-option label="English" value="en"></el-option>
-                  <el-option label="日本語" value="ja"></el-option>
-                  <el-option label="한국어" value="ko"></el-option>
-                  <el-option label="Français" value="fr"></el-option>
-                  <el-option label="Deutsch" value="de"></el-option>
-                </el-select>
-                <div class="hint">选择AI响应的主要语言</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="请求超时:" prop="timeout">
+                  style="width: 60%"
+                  v-model="viewForm.frequency_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-slider>
                 <el-input-number
                   disabled
-                  v-model="viewForm.timeout"
-                  :min="1"
-                  :max="60"
+                  v-model="viewForm.frequency_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
                 ></el-input-number>
-                <div class="hint">设置请求的最大等待时间(秒)</div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="角色名称:" prop="role_name">
-                <el-input
+              </div>
+              <div class="hint">防止重复,正值减少重复,负值增加重复</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="新话题偏好:" prop="presence_penalty">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
                   disabled
-                  style="width: 55%"
-                  v-model="viewForm.role_name"
-                  placeholder="例如: 客服专员"
-                ></el-input>
-                <div class="hint">为AI助手设定一个角色名称</div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="角色权限:" prop="role_permissions">
-                <el-input
-                  disabled
-                  style="width: 55%"
-                  v-model="viewForm.role_permissions"
-                  placeholder='["回答产品问题", "处理退换货请求", "升级复杂问题"]'
-                ></el-input>
-                <div class="hint">输入JSON数组,列出AI助手的具体权限</div>
-              </el-form-item>
-            </el-col>
-            <!-- <el-col :span="12">
-              <el-form-item label="角色描述:" prop="role_description">
-                <el-input
-                 style="width: 55%"
-                  v-model="viewForm.role_description"
-                  type="textarea"
-                  :rows="3"
-                  placeholder="例如: 你是一位专业的客服专员,负责解答客户关于我们产品和服务的问题。"
-                ></el-input>
-                <div class="hint">详细描述AI助手的角色和职责</div>
-              </el-form-item>
-            </el-col> -->
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="自定义变量:" prop="custom_variables">
-                <el-input
+                  style="width: 60%"
+                  v-model="viewForm.presence_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-slider>
+                <el-input-number
                   disabled
-                  style="width: 55%"
-                  v-model="viewForm.custom_variables"
-                  placeholder='{"custom_greeting": "很高兴为您服务!", "company_name": "ABC公司"}'
-                ></el-input>
-                <div class="hint">
-                  输入JSON对象,定义可在提示模板中使用的自定义变量
-                </div>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="自定义提示模板:" prop="custom_prompt">
-                <el-input
+                  v-model="viewForm.presence_penalty"
+                  :min="-2"
+                  :max="2"
+                  :step="0.1"
+                ></el-input-number>
+              </div>
+              <div class="hint">正值鼓励新话题,负值保持话题一致性</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="响应格式:" prop="response_format">
+              <el-input
+                disabled
+                style="width: 55%"
+                v-model="viewForm.response_format"
+                placeholder="text"
+              ></el-input>
+              <div class="hint">指定AI响应的格式,如text, json等</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="上下文窗口:" prop="context_window">
+              <div style="display: flex; justify-content: space-around">
+                <el-slider
                   disabled
                   style="width: 60%"
-                  v-model="viewForm.custom_prompt"
-                  type="textarea"
-                  :rows="6"
-                  placeholder="使用以下上下文来回答问题。如果你不知道答案,就说你不知道,不要试图编造答案。
-                      上下文: {context}
-                      人类: {question}
-                      AI助手: 让我根据提供的上下文来回答你的问题。{custom_greeting}"
-                ></el-input>
-                <div class="hint">
-                  自定义AI助手的回答模板,可使用变量如{context}, {question}等
-                </div>
-              </el-form-item>
-            </el-col>
-          </el-row>
-          <el-row :gutter="24">
-            <el-col :span="12">
-              <el-form-item label="是否启用API_key:" prop="generate_new_api_key">
-                <el-switch
-                  disabled
-                  v-model="viewForm.generate_new_api_key"
-                  active-color="#13ce66"
-                  inactive-color="#ff4949"
-                >
-                </el-switch>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="是否设为默认:" prop="is_default">
-                <el-switch
+                  v-model="viewForm.context_window"
+                  :min="1"
+                  :max="4096"
+                ></el-slider>
+                <el-input-number
                   disabled
-                  v-model="viewForm.is_default"
-                  active-color="#13ce66"
-                  inactive-color="#ff4949"
-                >
-                </el-switch>
-              </el-form-item>
-            </el-col>
-          </el-row>
-        </el-form>
-      </div>
-      <div class="footer">
-        <el-button @click="cancelApplication">取 消</el-button>
-        <el-button
-          type="primary"
-          v-if="type == 'add'"
-          @click="generateApplication"
-          >生成应用</el-button
-        >
-        <el-button type="primary" v-else-if="type == 'edit'" @click="submitEdit"
-          >确认修改</el-button
-        >
-      </div>
+                  v-model="viewForm.presence_penalty"
+                  :min="1"
+                  :max="4096"
+                  :step="1"
+                ></el-input-number>
+              </div>
+              <div class="hint">AI考虑的上下文token数量</div>
+            </el-form-item>
+          </el-col>
+          <!-- <el-col :span="12">
+            <el-form-item label="会话ID:" prop="session_id">
+              <el-input
+                disabled
+                style="width: 55%"
+                v-model="viewForm.session_id"
+                placeholder="可选"
+              ></el-input>
+              <div class="hint">特定会话的唯一标识符,如果有的话</div>
+            </el-form-item>
+          </el-col> -->
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="语言:" prop="language">
+              <el-select
+                disabled
+                v-model="viewForm.language"
+                style="width: 55%"
+              >
+                <el-option label="中文" value="zh"></el-option>
+                <el-option label="English" value="en"></el-option>
+                <el-option label="日本語" value="ja"></el-option>
+                <el-option label="한국어" value="ko"></el-option>
+                <el-option label="Français" value="fr"></el-option>
+                <el-option label="Deutsch" value="de"></el-option>
+              </el-select>
+              <div class="hint">选择AI响应的主要语言</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="请求超时:" prop="timeout">
+              <el-input-number
+                disabled
+                v-model="viewForm.timeout"
+                :min="1"
+                :max="60"
+              ></el-input-number>
+              <div class="hint">设置请求的最大等待时间(秒)</div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="角色名称:" prop="role_name">
+              <el-input
+                disabled
+                style="width: 55%"
+                v-model="viewForm.role_name"
+                placeholder="例如: 客服专员"
+              ></el-input>
+              <div class="hint">为AI助手设定一个角色名称</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="角色权限:" prop="role_permissions">
+              <el-input
+                disabled
+                style="width: 55%"
+                v-model="viewForm.role_permissions"
+                placeholder='["回答产品问题", "处理退换货请求", "升级复杂问题"]'
+              ></el-input>
+              <div class="hint">输入JSON数组,列出AI助手的具体权限</div>
+            </el-form-item>
+          </el-col>
+          <!-- <el-col :span="12">
+            <el-form-item label="角色描述:" prop="role_description">
+              <el-input
+               style="width: 55%"
+                v-model="viewForm.role_description"
+                type="textarea"
+                :rows="3"
+                placeholder="例如: 你是一位专业的客服专员,负责解答客户关于我们产品和服务的问题。"
+              ></el-input>
+              <div class="hint">详细描述AI助手的角色和职责</div>
+            </el-form-item>
+          </el-col> -->
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="自定义变量:" prop="custom_variables">
+              <el-input
+                disabled
+                style="width: 55%"
+                v-model="viewForm.custom_variables"
+                placeholder='{"custom_greeting": "很高兴为您服务!", "company_name": "ABC公司"}'
+              ></el-input>
+              <div class="hint">
+                输入JSON对象,定义可在提示模板中使用的自定义变量
+              </div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="自定义提示模板:" prop="custom_prompt">
+              <el-input
+                disabled
+                style="width: 60%"
+                v-model="viewForm.custom_prompt"
+                type="textarea"
+                :rows="6"
+                placeholder="使用以下上下文来回答问题。如果你不知道答案,就说你不知道,不要试图编造答案。
+                    上下文: {context}
+                    人类: {question}
+                    AI助手: 让我根据提供的上下文来回答你的问题。{custom_greeting}"
+              ></el-input>
+              <div class="hint">
+                自定义AI助手的回答模板,可使用变量如{context}, {question}等
+              </div>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="24">
+          <el-col :span="12">
+            <el-form-item label="是否启用API_key:" prop="generate_new_api_key">
+              <el-switch
+                disabled
+                v-model="viewForm.generate_new_api_key"
+                active-color="#13ce66"
+                inactive-color="#ff4949"
+              >
+              </el-switch>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="是否设为默认:" prop="is_default">
+              <el-switch
+                disabled
+                v-model="viewForm.is_default"
+                active-color="#13ce66"
+                inactive-color="#ff4949"
+              >
+              </el-switch>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
     </div>
-  </template>
-  
-  <script>
-  import axios from "axios";
-  import {
-    modelList,
-    listBuckets,
-    selectTypeList,
-    getBucketContents,
-    configSave,
-    configList,
-    configDelete,
-    application_types,
-    set_default,
-    configurationInfo,
-  } from "@/api/knowledge";
-  export default {
-    /*组件参数 接收来自父组件的数据*/
-    props: {},
-    /*局部注册的组件*/
-    components: {},
-    /*组件状态值*/
-    data() {
-      return {
-        AIform: {
-          chat_name: "",
-          modelLibrary: "ollama",
-          model_type: "chat",
-          model_name: "",
-          knowledge_base_names: [],
-          document_directories: [],
-          documents: [],
-          temperature: 0.7,
-          max_tokens: 150,
-          top_p: 1.0,
-          frequency_penalty: 0.0,
-          presence_penalty: 0.0,
-          response_format: "text",
-          context_window: 2048,
-          user_id: "user123",
-          session_id: "session456",
-          language: "en",
-          timeout: 30,
-          role_name: "Admin",
-          role_description: "",
-          role_permissions: "",
-          custom_variables: "",
-          custom_prompt: "",
-          application_type: "",
-          is_default: false,
-          generate_new_api_key: true,
-        },
-        /* 模型库 */
-        modelList: [],
-        /* 模型类型 */
-        modelTypeList: [],
-        /* 模型名称 */
-        modelNameList: [],
-        /* 知识库 */
-        kneList: [],
-        /* 文档目录 */
-        directoryList: [],
-        /* 文档 */
-        documentList: [],
-        bucket_id: "",
-        rules: {
-          chat_name: [
-            { required: true, message: "请填写应名称", trigger: "blur" },
-          ],
-          model_name: [
-            { required: true, message: "请选择模型名称", trigger: "change" },
-          ],
-          knowledge_base_names: [
-            {
-              required: true,
-              message: "请选择至少一个知识库",
-              trigger: "change",
-            },
-          ],
-          /* document_directories: [
-            { required: true, message: '请选择文档目录', trigger: 'change' }
-          ], */
-          documents: [
-            { required: true, message: "请选择至少一个文档", trigger: "change" },
-          ],
-        },
-        /* 配置类型列表 */
-        appTypeList: [],
-        id: "",
-        editForm: {
-          // 复制 AIform 的结构,但初始值为空
-          chat_name: "",
-          modelLibrary: "ollama",
-          model_type: "chat",
-          model_name: "",
-          knowledge_base_names: [],
-          document_directories: [],
-          documents: [],
-          temperature: 0.7,
-          max_tokens: 150,
-          top_p: 1.0,
-          frequency_penalty: 0.0,
-          presence_penalty: 0.0,
-          response_format: "text",
-          context_window: 2048,
-          user_id: "user123",
-          session_id: "session456",
-          language: "en",
-          timeout: 30,
-          role_name: "Admin",
-          role_description: "",
-          role_permissions: "",
-          custom_variables: "",
-          custom_prompt: "",
-          application_type: "",
-          is_default: false,
-          generate_new_api_key: true,
-        },
-        editDirectoryList: [],
-        editDocumentList: [],
-        type: "",
-        viewForm: {
-          // 复制 AIform 的结构,但初始值为空
-          chat_name: "",
-          modelLibrary: "ollama",
-          model_type: "chat",
-          model_name: "",
-          knowledge_base_names: [],
-          document_directories: [],
-          documents: [],
-          temperature: 0.7,
-          max_tokens: 150,
-          top_p: 1.0,
-          frequency_penalty: 0.0,
-          presence_penalty: 0.0,
-          response_format: "text",
-          context_window: 2048,
-          user_id: "user123",
-          session_id: "session456",
-          language: "en",
-          timeout: 30,
-          role_name: "Admin",
-          role_description: "",
-          role_permissions: "",
-          custom_variables: "",
-          custom_prompt: "",
-          application_type: "",
-          is_default: false,
-          generate_new_api_key: true,
-        },
-      };
-    },
-  
-    /*计算属性*/
-    computed: {
-      getKnowledgeBaseNames() {
-        const names = this.AIform.knowledge_base_names.map(
-          (id) => this.kneList.find((item) => item.id === id)?.name || id
-        );
-        if (names.length <= 2) {
-          return names.join(", ");
-        } else {
-          return `${names[0]}, ${names[1]} 等${names.length}个`;
-        }
+    <div class="footer">
+      <el-button @click="cancelApplication">取 消</el-button>
+      <el-button
+        type="primary"
+        v-if="type == 'add'"
+        @click="generateApplication"
+        >生成应用</el-button
+      >
+      <el-button type="primary" v-else-if="type == 'edit'" @click="submitEdit"
+        >确认修改</el-button
+      >
+    </div>
+  </div>
+</template>
+
+<script>
+import axios from "axios";
+import {
+  modelList,
+  listBuckets,
+  selectTypeList,
+  getBucketContents,
+  configSave,
+  configList,
+  configDelete,
+  application_types,
+  set_default,
+  configurationInfo,
+} from "@/api/knowledge";
+export default {
+  /*组件参数 接收来自父组件的数据*/
+  props: {},
+  /*局部注册的组件*/
+  components: {},
+  /*组件状态值*/
+  data() {
+    return {
+      AIform: {
+        chat_name: "",
+        modelLibrary: "ollama",
+        model_type: "chat",
+        model_name: "",
+        knowledge_base_names: [],
+        document_directories: [],
+        documents: [],
+        temperature: 0.7,
+        max_tokens: 150,
+        top_p: 1.0,
+        frequency_penalty: 0.0,
+        presence_penalty: 0.0,
+        response_format: "text",
+        context_window: 2048,
+        user_id: "user123",
+        session_id: "session456",
+        language: "en",
+        timeout: 30,
+        role_name: "Admin",
+        role_description: "",
+        role_permissions: "",
+        custom_variables: "",
+        custom_prompt: "",
+        application_type: "",
+        is_default: false,
+        generate_new_api_key: true,
       },
-      getDocumentNames() {
-        const names = this.AIform.documents.map(
-          (id) => this.documentList.find((item) => item.id === id)?.name || id
-        );
-        if (names.length <= 2) {
-          return names.join(", ");
-        } else {
-          return `${names[0]}, ${names[1]} 等${names.length}个`;
-        }
+      /* 模型库 */
+      modelList: [],
+      /* 模型类型 */
+      modelTypeList: [],
+      /* 模型名称 */
+      modelNameList: [],
+      /* 知识库 */
+      kneList: [],
+      /* 文档目录 */
+      directoryList: [],
+      /* 文档 */
+      documentList: [],
+      bucket_id: "",
+      rules: {
+        chat_name: [
+          { required: true, message: "请填写应名称", trigger: "blur" },
+        ],
+        model_name: [
+          { required: true, message: "请选择模型名称", trigger: "change" },
+        ],
+        knowledge_base_names: [
+          {
+            required: true,
+            message: "请选择至少一个知识库",
+            trigger: "change",
+          },
+        ],
+        /* document_directories: [
+          { required: true, message: '请选择文档目录', trigger: 'change' }
+        ], */
+        documents: [
+          { required: true, message: "请选择至少一个文档", trigger: "change" },
+        ],
       },
-      isDocumentSelectDisabled() {
-        return (
-          !this.AIform.knowledge_base_names.length ||
-          this.AIform.document_directories == ""
-        );
+      /* 配置类型列表 */
+      appTypeList: [],
+      id: "",
+      editForm: {
+        // 复制 AIform 的结构,但初始值为空
+        chat_name: "",
+        modelLibrary: "ollama",
+        model_type: "chat",
+        model_name: "",
+        knowledge_base_names: [],
+        document_directories: [],
+        documents: [],
+        temperature: 0.7,
+        max_tokens: 150,
+        top_p: 1.0,
+        frequency_penalty: 0.0,
+        presence_penalty: 0.0,
+        response_format: "text",
+        context_window: 2048,
+        user_id: "user123",
+        session_id: "session456",
+        language: "en",
+        timeout: 30,
+        role_name: "Admin",
+        role_description: "",
+        role_permissions: "",
+        custom_variables: "",
+        custom_prompt: "",
+        application_type: "",
+        is_default: false,
+        generate_new_api_key: true,
       },
+      editDirectoryList: [],
+      editDocumentList: [],
+      type: "",
+      viewForm: {
+        // 复制 AIform 的结构,但初始值为空
+        chat_name: "",
+        modelLibrary: "ollama",
+        model_type: "chat",
+        model_name: "",
+        knowledge_base_names: [],
+        document_directories: [],
+        documents: [],
+        temperature: 0.7,
+        max_tokens: 150,
+        top_p: 1.0,
+        frequency_penalty: 0.0,
+        presence_penalty: 0.0,
+        response_format: "text",
+        context_window: 2048,
+        user_id: "user123",
+        session_id: "session456",
+        language: "en",
+        timeout: 30,
+        role_name: "Admin",
+        role_description: "",
+        role_permissions: "",
+        custom_variables: "",
+        custom_prompt: "",
+        application_type: "",
+        is_default: false,
+        generate_new_api_key: true,
+      },
+    };
+  },
+
+  /*计算属性*/
+  computed: {
+    getKnowledgeBaseNames() {
+      const names = this.AIform.knowledge_base_names.map(
+        (id) => this.kneList.find((item) => item.id === id)?.name || id
+      );
+      if (names.length <= 2) {
+        return names.join(", ");
+      } else {
+        return `${names[0]}, ${names[1]} 等${names.length}个`;
+      }
     },
-  
-    /*侦听器*/
-    watch: {},
-  
-    /*
-     * el 被新创建的 vm.$ el 替换,并挂载到实例上去之后调用该钩子。
-     * 如果 root 实例挂载了一个文档内元素,当 mounted 被调用时 vm.$ el 也在文档内。
-     */
-    mounted() {
-      /* 初始化列表 */
-      this.init();
-      this.type = this.$route.query.type;
-      this.id = this.$route.query.id;
-      if (this.type == "edit") {
-        this.initEdit();
-      } else if (this.type == "view") {
-        this.initView();
+    getDocumentNames() {
+      const names = this.AIform.documents.map(
+        (id) => this.documentList.find((item) => item.id === id)?.name || id
+      );
+      if (names.length <= 2) {
+        return names.join(", ");
+      } else {
+        return `${names[0]}, ${names[1]} 等${names.length}个`;
       }
     },
-  
-    /*组件方法*/
-    methods: {
-      /* 编辑 */
-      /* 编辑确认修改 */
-      submitEdit() {
-        this.$refs.editFormRef.validate(async (valid) => {
-          if (valid) {
-            try {
-              const convertedForm = { ...this.editForm };
-              console.log(this.editForm);
-              // 转换知识库、文档目录和文档的ID为名称
-              /*  convertedForm.knowledge_base_names = this.safeGetNamesByIds(this.editForm.knowledge_base_names, this.kneList); */
-              /*  convertedForm.documents = this.safeGetNamesByIds(this.editForm.documents, this.editDocumentList); */
-              convertedForm.document_directories = this.safeGetNamesByIds(
-                this.editForm.document_directories,
-                this.editDirectoryList
-              );
-              if (convertedForm.document_directories.length === 0) {
-                convertedForm.document_directories = ["全部"];
-              }
-  
-              console.log("Converted form for edit:", convertedForm);
-  
-              const response = await axios.post(
-                `${process.env.VUE_APP_BASE_API}/chatbot/configuration/update/`,
-                convertedForm,
-                {
-                  headers: {
-                    "Content-Type": "application/json",
-                  },
-                }
-              );
-  
-              if (response.status === 200) {
-                this.$message.success("应用更新成功");
-                this.$router.push({
-                  path: "/knowledge/chatPage/index",
-                }); //跳转到聊天应用页面
-                /* this.editDialogVisible = false; */
-                /* this.fetchApplicationList(); */
-              } else {
-                this.$message.error(response.data.message || "应用更新失败");
-              }
-            } catch (error) {
-              console.error("Error updating application:", error);
-              this.$message.error("应用更新失败,请稍后重试");
-            }
-          } else {
-            this.$message.error("请填写所有必填字段");
-            return false;
-          }
-        });
-      },
-      handleEditKnowledgeBaseChange(val) {
-        // 重置目录和文档选择
-        this.editForm.document_directories = [];
-        this.editForm.documents = [];
-        this.editDocumentList = [];
-        // 加载新选择的知识库对应的目录列表
-        this.loadEditDirectoryList(val);
-      },
-      handleEditDirectoryChange(val) {
-        // 重置文档选择
-        this.editForm.documents = [];
-  
-        // 加载选中目录对应的文档列表
-        this.loadEditDocumentList(val);
-      },
-      /* 知识库选择监听 */
-      async loadEditDirectoryList(val) {
-        this.editDirectoryList = []; // 清空现有目录列表
-        let totalDocuments = 0;
-        let otherFolderCount = 0;
-  
-        for (const kbName of val) {
-          // 根据知识库名称找到对应的 ID
-          const kbId = this.kneList.find((kb) => kb.name === kbName)?.id;
-  
-          /* if (!kbId) {
-            console.error(`No matching knowledge base found for name: ${kbName}`);
-            continue;
-          } */
-  
-          const typeForm = {
-            page: 1,
-            pageSize: 9999,
-            kb_id: kbName,
-          };
-  
+    isDocumentSelectDisabled() {
+      return (
+        !this.AIform.knowledge_base_names.length ||
+        this.AIform.document_directories == ""
+      );
+    },
+  },
+
+  /*侦听器*/
+  watch: {},
+
+  /*
+   * el 被新创建的 vm.$ el 替换,并挂载到实例上去之后调用该钩子。
+   * 如果 root 实例挂载了一个文档内元素,当 mounted 被调用时 vm.$ el 也在文档内。
+   */
+  mounted() {
+    /* 初始化列表 */
+    this.init();
+    this.type = this.$route.query.type;
+    this.id = this.$route.query.id;
+    /* if (this.type == "edit") {
+       this.initEdit();
+     
+    } else */ if (this.type == "view") {
+      this.initView();
+    }
+  },
+
+  /*组件方法*/
+  methods: {
+    /* 编辑 */
+    handleEditDocumentChange(selectedValues) {
+      if (selectedValues.includes("all")) {
+        // 如果选择了"全部",则清空其他选项
+        this.editForm.documents = ["all"];
+      } else {
+        // 如果没有选择"全部",则限制最多选择10个文档
+        if (selectedValues.length > 10) {
+          this.editForm.documents = selectedValues.slice(0, 10);
+          this.$message.warning("最多只能选择10个文档");
+        }
+      }
+    },
+    /* 编辑确认修改 */
+    submitEdit() {
+      this.$refs.editFormRef.validate(async (valid) => {
+        if (valid) {
           try {
-            const res = await selectTypeList(typeForm);
-            if (res.data) {
-              this.editDirectoryList = [
-                ...new Set([...this.editDirectoryList, ...res.data.dataList]),
-              ];
-  
-              res.data.dataList.forEach((folder) => {
-                if (folder.id === "other") {
-                  otherFolderCount += folder.document_count || 0;
-                } else {
-                  totalDocuments += folder.document_count || 0;
-                }
-              });
+            const convertedForm = { ...this.editForm };
+            console.log(this.editForm);
+            // 转换知识库、文档目录和文档的ID为名称
+            /*  convertedForm.knowledge_base_names = this.safeGetNamesByIds(this.editForm.knowledge_base_names, this.kneList); */
+            /*  convertedForm.documents = this.safeGetNamesByIds(this.editForm.documents, this.editDocumentList); */
+            // 处理文档选择
+            if (
+              convertedForm.documents.includes("all") ||
+              convertedForm.documents.length === 0
+            ) {
+              convertedForm.documents = []; // 全选或未选择时传空数组给后台
+            } else {
+              /* convertedForm.documents = this.safeGetNamesByIds(
+                convertedForm.documents,
+                this.editDocumentList
+              ); */
             }
-          } catch (error) {
-            console.error(
-              `Error loading directory list for kb_id ${kbId}:`,
-              error
+            convertedForm.document_directories = this.safeGetNamesByIds(
+              this.editForm.document_directories,
+              this.editDirectoryList
+            );
+            if (convertedForm.document_directories.length === 0) {
+              convertedForm.document_directories = ["全部"];
+            }
+
+            console.log("Converted form for edit:", convertedForm);
+
+            const response = await axios.post(
+              `${process.env.VUE_APP_BASE_API}/chatbot/configuration/update/`,
+              convertedForm,
+              {
+                headers: {
+                  "Content-Type": "application/json",
+                },
+              }
             );
+
+            if (response.status === 200) {
+              this.$message.success("应用更新成功");
+              this.$router.push({
+                path: "/knowledge/chatPage/index",
+              }); //跳转到聊天应用页面
+              /* this.editDialogVisible = false; */
+              /* this.fetchApplicationList(); */
+            } else {
+              this.$message.error(response.data.message || "应用更新失败");
+            }
+          } catch (error) {
+            console.error("Error updating application:", error);
+            this.$message.error("应用更新失败,请稍后重试");
           }
+        } else {
+          this.$message.error("请填写所有必填字段");
+          return false;
         }
-  
-        this.editDirectoryList.unshift({
-          id: "001",
-          name: "全部",
-          document_count: totalDocuments + otherFolderCount,
-        });
-      },
-      /* 监听目录选择 */
-      loadEditDocumentList(val) {
-        // 找到选中目录的名称
-        const selectedDirectoryName = val;
-        const id = this.directoryList.find((el) => el.id == val);
-        // 从 kneList 中找到对应的知识库
-        const selectedKnowledgeBase = this.kneList.find(
-          (kb) => kb.id === this.editForm.knowledge_base_names[0]
-        );
-  
-        /* if (!selectedKnowledgeBase) {
-          console.error('No matching knowledge base found');
-          return;
+      });
+    },
+    handleEditKnowledgeBaseChange(val) {
+      // 重置目录和文档选择
+      this.editForm.document_directories = [];
+      this.editForm.documents = [];
+      this.editDocumentList = [];
+      // 加载新选择的知识库对应的目录列表
+      this.loadEditDirectoryList(val);
+    },
+    handleEditDirectoryChange(val) {
+      // 重置文档选择
+      this.editForm.documents = [];
+
+      // 加载选中目录对应的文档列表
+      this.loadEditDocumentList(val);
+    },
+    /* 知识库选择监听 */
+    async loadEditDirectoryList(val) {
+      this.editDirectoryList = []; // 清空现有目录列表
+      let totalDocuments = 0;
+      let otherFolderCount = 0;
+
+      for (const kbName of val) {
+        // 根据知识库名称找到对应的 ID
+        const kbId = this.kneList.find((kb) => kb.name === kbName)?.id;
+
+        /* if (!kbId) {
+          console.error(`No matching knowledge base found for name: ${kbName}`);
+          continue;
         } */
-        let queryForm = {
+
+        const typeForm = {
           page: 1,
           pageSize: 9999,
-          bucket_id: selectedKnowledgeBase.id,
-          doc_type_id:
-            selectedDirectoryName === "001"
-              ? ""
-              : this.getDirectoryIdByName(selectedDirectoryName),
+          kb_id: kbName,
         };
-  
-        getBucketContents(queryForm).then((res) => {
-          this.editDocumentList = res.data.documents;
-        });
-      },
-      // 添加一个辅助方法来根据目录名称获取目录ID
-      getDirectoryIdByName(directoryName) {
-        const directory = this.editDirectoryList.find(
-          (dir) => dir.name === directoryName
-        );
-        return directory ? directory.id : null;
-      },
-  
-      /* 新增 */
-      /* 重置表单 */
-      resetForm() {
-        if (this.$refs.AIformRef) {
-          this.$refs.AIformRef.resetFields();
+
+        try {
+          const res = await selectTypeList(typeForm);
+          if (res.data) {
+            this.editDirectoryList = [
+              ...new Set([...this.editDirectoryList, ...res.data.dataList]),
+            ];
+
+            res.data.dataList.forEach((folder) => {
+              if (folder.id === "other") {
+                otherFolderCount += folder.document_count || 0;
+              } else {
+                totalDocuments += folder.document_count || 0;
+              }
+            });
+          }
+        } catch (error) {
+          console.error(
+            `Error loading directory list for kb_id ${kbId}:`,
+            error
+          );
         }
-        this.AIform = {
-          chat_name: "",
-          modelLibrary: "ollama",
-          model_type: "chat",
-          model_name: "",
-          knowledge_base_names: [],
-          document_directories: [],
-          documents: [],
-          temperature: 0.7,
-          max_tokens: 150,
-          top_p: 1.0,
-          frequency_penalty: 0.0,
-          presence_penalty: 0.0,
-          response_format: "",
-          context_window: 2048,
-          user_id: "",
-          session_id: "",
-          language: "en",
-          timeout: 30,
-          role_name: "Admin",
-          role_description: "",
-          role_permissions: "",
-          custom_variables: "",
-          custom_prompt: "",
-          application_type: "",
-          is_default: false,
-          generate_new_api_key: true,
-        };
-      },
-      /* 取消 */
-      cancelApplication() {
-        if (this.type == "view") {
-          this.resetForm();
-          this.$router.push({
-            path: "/knowledge/chatPage/index",
-          });
-        } else {
-          this.$confirm("确认取消?未保存的更改将会丢失。")
-            .then((_) => {
-              this.resetForm();
-              this.$router.push({
-                path: "/knowledge/chatPage/index",
-              });
-            })
-            .catch((_) => {});
+      }
+
+      this.editDirectoryList.unshift({
+        id: "001",
+        name: "全部",
+        document_count: totalDocuments + otherFolderCount,
+      });
+    },
+    /* 监听目录选择 */
+    loadEditDocumentList(val) {
+      // 找到选中目录的名称
+      const selectedDirectoryName = val;
+      const id = this.directoryList.find((el) => el.id == val);
+      // 从 kneList 中找到对应的知识库
+      const selectedKnowledgeBase = this.kneList.find(
+        (kb) => kb.id === this.editForm.knowledge_base_names[0]
+      );
+
+      /* if (!selectedKnowledgeBase) {
+        console.error('No matching knowledge base found');
+        return;
+      } */
+      let queryForm = {
+        page: 1,
+        pageSize: 9999,
+        bucket_id: selectedKnowledgeBase.id,
+        doc_type_id:
+          selectedDirectoryName === "001"
+            ? ""
+            : this.getDirectoryIdByName(selectedDirectoryName),
+      };
+
+      getBucketContents(queryForm).then((res) => {
+        this.editDocumentList = res.data.documents;
+      });
+    },
+    // 添加一个辅助方法来根据目录名称获取目录ID
+    getDirectoryIdByName(directoryName) {
+      const directory = this.editDirectoryList.find(
+        (dir) => dir.name === directoryName
+      );
+      return directory ? directory.id : null;
+    },
+
+    /* 新增 */
+    /* 重置表单 */
+    resetForm() {
+      if (this.$refs.AIformRef) {
+        this.$refs.AIformRef.resetFields();
+      }
+      this.AIform = {
+        chat_name: "",
+        modelLibrary: "ollama",
+        model_type: "chat",
+        model_name: "",
+        knowledge_base_names: [],
+        document_directories: [],
+        documents: [],
+        temperature: 0.7,
+        max_tokens: 150,
+        top_p: 1.0,
+        frequency_penalty: 0.0,
+        presence_penalty: 0.0,
+        response_format: "",
+        context_window: 2048,
+        user_id: "",
+        session_id: "",
+        language: "en",
+        timeout: 30,
+        role_name: "Admin",
+        role_description: "",
+        role_permissions: "",
+        custom_variables: "",
+        custom_prompt: "",
+        application_type: "",
+        is_default: false,
+        generate_new_api_key: true,
+      };
+    },
+    /* 取消 */
+    cancelApplication() {
+      if (this.type == "view") {
+        this.resetForm();
+        this.$router.push({
+          path: "/knowledge/chatPage/index",
+        });
+      } else {
+        this.$confirm("确认取消?未保存的更改将会丢失。")
+          .then((_) => {
+            this.resetForm();
+            this.$router.push({
+              path: "/knowledge/chatPage/index",
+            });
+          })
+          .catch((_) => {});
+      }
+    },
+    handleDocumentChange(selectedValues) {
+      if (selectedValues.includes("all")) {
+        // 如果选择了"全部",则清空其他选项
+        this.AIform.documents = ["all"];
+      } else {
+        // 如果没有选择"全部",则限制最多选择10个文档
+        if (selectedValues.length > 10) {
+          this.AIform.documents = selectedValues.slice(0, 10);
+          this.$message.warning("最多只能选择10个文档");
         }
-      },
-      /* 新增聊天应用 */
-      generateApplication() {
-        this.$refs.AIformRef.validate(async (valid) => {
-          if (valid) {
-            try {
-              // 创建一个新对象来存储转换后的数据
-              const convertedForm = { ...this.AIform };
-  
-              // 将知识库 ID 转换为名称
-              convertedForm.knowledge_base_names = this.safeGetNamesByIds(
-                this.AIform.knowledge_base_names,
-                this.kneList
-              );
-  
-              // 将文档 ID 转换为名称
+      }
+    },
+    /* 新增聊天应用 */
+    generateApplication() {
+      this.$refs.AIformRef.validate(async (valid) => {
+        if (valid) {
+          try {
+            // 创建一个新对象来存储转换后的数据
+            const convertedForm = { ...this.AIform };
+
+            // 将知识库 ID 转换为名称
+            convertedForm.knowledge_base_names = this.safeGetNamesByIds(
+              this.AIform.knowledge_base_names,
+              this.kneList
+            );
+
+            /* // 将文档 ID 转换为名称
+            convertedForm.documents = this.safeGetNamesByIds(
+              this.AIform.documents,
+              this.documentList
+            ); */
+            // 处理文档选择
+            if (
+              convertedForm.documents.includes("all") ||
+              convertedForm.documents.length === 0
+            ) {
+              convertedForm.documents = []; // 全选或未选择时传空数组给后台
+            } else {
               convertedForm.documents = this.safeGetNamesByIds(
-                this.AIform.documents,
+                convertedForm.documents,
                 this.documentList
               );
-  
-              // 将文档目录 ID 转换为名称,如果为空则传递 '全部'
-              convertedForm.document_directories = this.safeGetNamesByIds(
-                this.AIform.document_directories,
-                this.directoryList
-              );
-              if (convertedForm.document_directories.length === 0) {
-                convertedForm.document_directories = ["全部"];
-              }
-  
-              console.log("Converted form:", convertedForm);
-  
-              // 使用 axios 发送 POST 请求
-              const response = await axios.post(
-                `${process.env.VUE_APP_BASE_API}/chatbot/configCreart/`,
-                convertedForm,
-                {
-                  headers: {
-                    "Content-Type": "application/json",
-                  },
-                }
-              );
-  
-              if (response.status === 200) {
-                this.$message.success("应用生成成功");
-                this.resetForm();
-                /* this.fetchApplicationList(); */
-                this.$router.push({
-                  path: "/knowledge/chatPage/index",
-                }); //跳转到聊天应用页面
-                // 可选:重定向到新应用或更新 UI
-              } else {
-                this.$message.error(response.data.message || "应用生成失败");
-              }
-            } catch (error) {
-              console.error("Error generating application:", error);
-              this.$message.error("应用生成失败,请稍后重试");
             }
-          } else {
-            this.$message.error("请填写所有必填字段");
-            return false;
-          }
-        });
-      },
-      /* 数据处理方法 */
-      // 安全的辅助方法:通过 ID 数组获取名称数组
-      safeGetNamesByIds(ids, list) {
-        if (!Array.isArray(ids)) {
-          console.warn("Expected an array of ids, but received:", ids);
-          return [];
-        }
-        return ids
-          .map((id) => {
-            if (id === "001") {
-              return "全部";
+
+            // 将文档目录 ID 转换为名称,如果为空则传递 '全部'
+            convertedForm.document_directories = this.safeGetNamesByIds(
+              this.AIform.document_directories,
+              this.directoryList
+            );
+            if (convertedForm.document_directories.length === 0) {
+              convertedForm.document_directories = ["全部"];
             }
-            const item = list.find((item) => item.id === id);
-            return item ? item.name : "";
-          })
-          .filter((name) => name !== "");
-      },
-      /* 知识库选择监听联动 */
-      handleKnowledgeBaseChange(val) {
-        // 重置目录和文档选择
-        this.AIform.document_directories = [];
-        this.AIform.documents = [];
-        this.documentList = [];
-        this.bucket_id = val[0];
-        // 根据选中的知识库加载目录列表
-        // 这里需要调用后端 API 来获取目录列表
-        this.loadDirectoryList(val);
-      },
-      handleDirectoryChange(val) {
-        // 重置文档选择
-        this.AIform.documents = [];
-  
-        // 根据选中的目录加载文档列表
-        // 这里需要调用后端 API 来获取文档列表
-        this.loadDocumentList(val);
-      },
-      async loadDirectoryList(val) {
-        this.directoryList = []; // 清空现有目录列表
-        let totalDocuments = 0;
-        let otherFolderCount = 0;
-  
-        for (const kbId of val) {
-          const typeForm = {
-            page: 1,
-            pageSize: 9999,
-            kb_id: kbId,
-          };
-  
-          try {
-            const res = await selectTypeList(typeForm);
-            // 假设 res.data 包含目录列表
-            if (res.data) {
-              // 将新的目录添加到列表中,避免重复
-              this.directoryList = [
-                ...new Set([...this.directoryList, ...res.data.dataList]),
-              ];
-              console.log(res.data.dataList);
-              // 计算总文档数和其他文件夹数量
-              res.data.dataList.forEach((folder) => {
-                if (folder.id === "other") {
-                  otherFolderCount += folder.document_count || 0;
-                } else {
-                  totalDocuments += folder.document_count || 0;
-                }
-              });
+
+            console.log("Converted form:", convertedForm);
+
+            // 使用 axios 发送 POST 请求
+            const response = await axios.post(
+              `${process.env.VUE_APP_BASE_API}/chatbot/configCreart/`,
+              convertedForm,
+              {
+                headers: {
+                  "Content-Type": "application/json",
+                },
+              }
+            );
+
+            if (response.status === 200) {
+              this.$message.success("应用生成成功");
+              this.resetForm();
+              /* this.fetchApplicationList(); */
+              this.$router.push({
+                path: "/knowledge/chatPage/index",
+              }); //跳转到聊天应用页面
+              // 可选:重定向到新应用或更新 UI
+            } else {
+              this.$message.error(response.data.message || "应用生成失败");
             }
           } catch (error) {
-            console.error(
-              `Error loading directory list for kb_id ${kbId}:`,
-              error
-            );
-            // 可以在这里添加错误处理,比如显示一个错误提示
+            console.error("Error generating application:", error);
+            this.$message.error("应用生成失败,请稍后重试");
           }
+        } else {
+          this.$message.error("请填写所有必填字段");
+          return false;
         }
-  
-        // 在列表开头插入"全部"选项
-        this.directoryList.unshift({
-          id: "001",
-          name: "全部",
-          /*  document_count: totalDocuments + otherFolderCount, */
-        });
-      },
-      /* 目录选择监听 */
-      handleDirectoryChange(val) {
-        // 重置文档选择
-        this.AIform.documents = [];
-  
-        // 根据选中的目录加载文档列表
-        // 这里需要调用后端 API 来获取文档列表
-        this.loadDocumentList(val);
-      },
-      loadDocumentList(val) {
-        const id = this.directoryList.find((el) => el.id == val);
-        let queryForm = {
+      });
+    },
+    /* 数据处理方法 */
+    // 安全的辅助方法:通过 ID 数组获取名称数组
+    safeGetNamesByIds(ids, list) {
+      if (!Array.isArray(ids)) {
+        console.warn("Expected an array of ids, but received:", ids);
+        return [];
+      }
+      return ids
+        .map((id) => {
+          if (id === "001") {
+            return "全部";
+          }
+          const item = list.find((item) => item.id === id);
+          return item ? item.name : "";
+        })
+        .filter((name) => name !== "");
+    },
+    /* 知识库选择监听联动 */
+    handleKnowledgeBaseChange(val) {
+      // 重置目录和文档选择
+      this.AIform.document_directories = [];
+      this.AIform.documents = [];
+      this.documentList = [];
+      this.bucket_id = val[0];
+      // 根据选中的知识库加载目录列表
+      // 这里需要调用后端 API 来获取目录列表
+      this.loadDirectoryList(val);
+    },
+    handleDirectoryChange(val) {
+      // 重置文档选择
+      this.AIform.documents = [];
+
+      // 根据选中的目录加载文档列表
+      // 这里需要调用后端 API 来获取文档列表
+      this.loadDocumentList(val);
+    },
+    async loadDirectoryList(val) {
+      this.directoryList = []; // 清空现有目录列表
+      let totalDocuments = 0;
+      let otherFolderCount = 0;
+
+      for (const kbId of val) {
+        const typeForm = {
           page: 1,
           pageSize: 9999,
-          bucket_id: val == "001" ? this.bucket_id : id.kb_id, //this.bucket_id,
-          doc_type_id: val == "001" ? "" : val,
+          kb_id: kbId,
         };
-        getBucketContents(queryForm).then((res) => {
-          this.documentList = res.data.documents;
-        });
-      },
-      /* 获取列表 */
-      init() {
-        /* 模型库 */
-        modelList({ model_type: "model" }).then((res) => {
-          this.modelNameList = res.data;
-        });
-        /* 知识库 */
-        listBuckets({ user_id: this.$store.state.user.id }).then((res) => {
-          this.kneList = res.data;
-        });
-        /* 应用列表 */
-        configList().then((res) => {
-          this.knowledgeBases = res.data;
-          console.log(res);
-        });
-        /* 获取应用类型 */
-        application_types().then((res) => {
-          if (res.status !== 200) return;
-          this.appTypeList = res.data.application_types;
-        });
-      },
-      /* 编辑查看 */
-      initEdit() {
-        // 根据 card 的数据填充 editForm
-        this.editForm = JSON.parse(JSON.stringify(this.$route.query.card)); // 深拷贝以避免直接修改原对象
-  
-        // 处理 knowledge_base_names
-        this.editForm.knowledge_base_names =
-          this.editForm.knowledge_base_names.map((name) => {
-            const kb = this.kneList.find((kb) => kb.name === name);
-            return kb ? kb.id : name; // 如果找不到对应的知识库,保留原名称
-          });
-  
-        // 处理 role_permissions
-        if (this.editForm.role_permissions) {
-          if (typeof this.editForm.role_permissions !== "string") {
-            try {
-              this.editForm.role_permissions = JSON.stringify(
-                this.editForm.role_permissions
-              );
-            } catch (error) {
-              console.error("Error stringifying role_permissions:", error);
-              this.editForm.role_permissions = "";
-            }
+
+        try {
+          const res = await selectTypeList(typeForm);
+          // 假设 res.data 包含目录列表
+          if (res.data) {
+            // 将新的目录添加到列表中,避免重复
+            this.directoryList = [
+              ...new Set([...this.directoryList, ...res.data.dataList]),
+            ];
+            console.log(res.data.dataList);
+            // 计算总文档数和其他文件夹数量
+            res.data.dataList.forEach((folder) => {
+              if (folder.id === "other") {
+                otherFolderCount += folder.document_count || 0;
+              } else {
+                totalDocuments += folder.document_count || 0;
+              }
+            });
           }
-        } else {
-          this.editForm.role_permissions = "";
-        }
-  
-        // 处理 custom_variables
-        if (this.editForm.custom_variables) {
-          this.editForm.custom_variables = JSON.stringify(
-            this.editForm.custom_variables
+        } catch (error) {
+          console.error(
+            `Error loading directory list for kb_id ${kbId}:`,
+            error
           );
-        } else {
-          this.editForm.custom_variables = "";
+          // 可以在这里添加错误处理,比如显示一个错误提示
         }
-  
-        // 加载知识库对应的目录列表
-        this.loadEditDirectoryList(this.editForm.knowledge_base_names);
-        /* this.loadEditDocumentList(this.editForm.document_directories[0]); */
-      },
-      /* 查看 */
-      initView() {
-        // 根据 card 的数据填充 viewForm
-        this.viewForm = JSON.parse(JSON.stringify(this.$route.query.card)); // 深拷贝以避免直接修改原对象
-  
-        // 处理 knowledge_base_names
-        this.viewForm.knowledge_base_names =
-          this.viewForm.knowledge_base_names.map((name) => {
-            const kb = this.kneList.find((kb) => kb.name === name);
-            return kb ? kb.id : name; // 如果找不到对应的知识库,保留原名称
-          });
-  
-        // 处理 role_permissions
-        if (this.viewForm.role_permissions) {
-          if (typeof this.viewForm.role_permissions !== "string") {
-            try {
-              this.viewForm.role_permissions = JSON.stringify(
-                this.viewForm.role_permissions
-              );
-            } catch (error) {
-              console.error("Error stringifying role_permissions:", error);
-              this.viewForm.role_permissions = "";
+      }
+
+      // 在列表开头插入"全部"选项
+      this.directoryList.unshift({
+        id: "001",
+        name: "全部",
+        /*  document_count: totalDocuments + otherFolderCount, */
+      });
+    },
+    /* 目录选择监听 */
+    handleDirectoryChange(val) {
+      // 重置文档选择
+      this.AIform.documents = [];
+
+      // 根据选中的目录加载文档列表
+      // 这里需要调用后端 API 来获取文档列表
+      this.loadDocumentList(val);
+    },
+    loadDocumentList(val) {
+      const id = this.directoryList.find((el) => el.id == val);
+      let queryForm = {
+        page: 1,
+        pageSize: 9999,
+        bucket_id: val == "001" ? this.bucket_id : id.kb_id, //this.bucket_id,
+        doc_type_id: val == "001" ? "" : val,
+      };
+      getBucketContents(queryForm).then((res) => {
+        this.documentList = res.data.documents;
+      });
+    },
+    /* 获取列表 */
+    init() {
+      /* 模型库 */
+      modelList({ model_type: "model" }).then((res) => {
+        this.modelNameList = res.data;
+      });
+      /* 知识库 */
+      listBuckets({ user_id: this.$store.state.user.id }).then((res) => {
+        this.kneList = res.data;
+        if (this.$route.query.type == "edit") {
+          this.initEdit();
+        }
+      });
+      /* 应用列表 */
+      configList().then((res) => {
+        this.knowledgeBases = res.data;
+        console.log(res);
+      });
+      /* 获取应用类型 */
+      application_types().then((res) => {
+        if (res.status !== 200) return;
+        this.appTypeList = res.data.application_types;
+      });
+    },
+    /* 编辑查看 */
+    initEdit() {
+      // 根据 card 的数据填充 editForm
+      this.editForm = JSON.parse(JSON.stringify(this.$route.query.card)); // 深拷贝以避免直接修改原对象
+
+      // 处理 knowledge_base_names
+      this.editForm.knowledge_base_names =
+        this.editForm.knowledge_base_names.map((name) => {
+          const kb = this.kneList.find((kb) => kb.name == name);
+          console.log(this.kneList);
+          return kb ? kb.id : name; // 如果找不到对应的知识库,保留原名称
+        });
+      // 处理 role_permissions
+      if (this.editForm.role_permissions) {
+        if (typeof this.editForm.role_permissions !== "string") {
+          try {
+            this.editForm.role_permissions = JSON.stringify(
+              this.editForm.role_permissions
+            );
+          } catch (error) {
+            console.error("Error stringifying role_permissions:", error);
+            this.editForm.role_permissions = "";
+          }
+        }
+      } else {
+        this.editForm.role_permissions = "";
+      }
+
+      // 处理 custom_variables
+      if (this.editForm.custom_variables) {
+        this.editForm.custom_variables = JSON.stringify(
+          this.editForm.custom_variables
+        );
+      } else {
+        this.editForm.custom_variables = "";
+      }
+
+      // 加载知识库对应的目录列表
+      this.loadEditDirectoryList(this.editForm.knowledge_base_names).then(
+        () => {
+          // 在目录列表加载完成后,设置选中的目录
+          if (
+            this.editForm.document_directories &&
+            this.editForm.document_directories.length > 0
+          ) {
+            const dirId = this.editDirectoryList.find(
+              (dir) => dir.name === this.editForm.document_directories[0]
+            )?.id;
+            if (dirId) {
+              this.editForm.document_directories = dirId;
+              // 加载文档列表
+              this.loadEditDocumentList(dirId).then(() => {
+                // 在文档列表加载完成后,设置选中的文档
+                if (
+                  this.editForm.documents &&
+                  this.editForm.documents.length > 0
+                ) {
+                  this.editForm.documents = this.editDocumentList
+                    .filter((doc) => this.editForm.documents.includes(doc.name))
+                    .map((doc) => doc.id);
+                }
+              });
             }
           }
-        } else {
-          this.viewForm.role_permissions = "";
         }
-  
-        // 处理 custom_variables
-        if (this.viewForm.custom_variables) {
-          this.viewForm.custom_variables = JSON.stringify(
-            this.viewForm.custom_variables
-          );
-        } else {
-          this.viewForm.custom_variables = "";
+      );
+      /* this.loadEditDocumentList(this.editForm.document_directories[0]); */
+    },
+    /* 查看 */
+    initView() {
+      // 根据 card 的数据填充 viewForm
+      this.viewForm = JSON.parse(JSON.stringify(this.$route.query.card)); // 深拷贝以避免直接修改原对象
+
+      // 处理 knowledge_base_names
+      this.viewForm.knowledge_base_names =
+        this.viewForm.knowledge_base_names.map((name) => {
+          const kb = this.kneList.find((kb) => kb.name === name);
+          return kb ? kb.id : name; // 如果找不到对应的知识库,保留原名称
+        });
+
+      // 处理 role_permissions
+      if (this.viewForm.role_permissions) {
+        if (typeof this.viewForm.role_permissions !== "string") {
+          try {
+            this.viewForm.role_permissions = JSON.stringify(
+              this.viewForm.role_permissions
+            );
+          } catch (error) {
+            console.error("Error stringifying role_permissions:", error);
+            this.viewForm.role_permissions = "";
+          }
         }
-  
-        // 加载知识库对应的目录列表
-        this.loadEditDirectoryList(this.viewForm.knowledge_base_names);
-      },
+      } else {
+        this.viewForm.role_permissions = "";
+      }
+
+      // 处理 custom_variables
+      if (this.viewForm.custom_variables) {
+        this.viewForm.custom_variables = JSON.stringify(
+          this.viewForm.custom_variables
+        );
+      } else {
+        this.viewForm.custom_variables = "";
+      }
+
+      /* // 处理文档选择
+       if (this.editForm.documents.length === 0 || this.editForm.documents.includes('全部')) {
+        this.editForm.documents = ['all'];
+      } else {
+        // 将文档名称转换为ID
+        this.editForm.documents = this.editForm.documents.map(docName => {
+          const doc = this.editDocumentList.find(d => d.name === docName);
+          return doc ? doc.id : docName;
+        });
+      } */
+      // 加载知识库对应的目录列表
+      this.loadEditDirectoryList(this.viewForm.knowledge_base_names);
     },
-  };
-  </script>
-  <style lang='scss' scoped>
-  .header {
-    margin-left: 20px;
-    h2 {
-      margin-bottom: 0px;
-    }
+  },
+};
+</script>
+<style lang='scss' scoped>
+.header {
+  margin-left: 20px;
+  h2 {
+    margin-bottom: 0px;
   }
-  .center {
-    margin: 10px;
-    ::v-deep .el-form--inline .el-form-item {
-      display: block;
-    }
-    ::v-deep .el-input-number--medium {
-      width: 150px;
-    }
+}
+.center {
+  margin: 10px;
+  ::v-deep .el-form--inline .el-form-item {
+    display: block;
   }
-  .footer {
-    display: flex;
-    justify-content: flex-end;
-    margin: 0 100px 20px;
+  ::v-deep .el-input-number--medium {
+    width: 150px;
   }
-  </style>
+}
+.footer {
+  display: flex;
+  justify-content: flex-end;
+  margin: 0 100px 20px;
+}
+</style>

+ 8 - 7
src/views/knowledgeMenu/category/knowledgeSet.vue

@@ -88,6 +88,7 @@
             label="文件名称"
             align="center"
             sortable="custom"
+            width="300"
           >
             <template #default="scope">
               <span>{{ scope.row.name }}</span>
@@ -126,7 +127,7 @@
                     circle
                     icon="el-icon-view"
                     v-if="checkAuth('/document/update')"
-                    style="font-size: 20px"
+                    style="font-size: 15px"
                     @click="getName(scope.row)"
                   ></el-button
                 ></el-tooltip>
@@ -144,7 +145,7 @@
                     icon="el-icon-caret-right"
                     circle
                     @click="analysis(scope.row)"
-                    style="font-size: 20px"
+                    style="font-size: 15px"
                   >
                   </el-button>
                   <el-button
@@ -153,7 +154,7 @@
                     icon="el-icon-loading"
                     circle
                     :disabled="true"
-                    style="font-size: 20px"
+                    style="font-size: 15px"
                   >
                   </el-button>
                 </el-tooltip>
@@ -169,7 +170,7 @@
                     circle
                     icon="el-icon-tickets"
                     v-if="checkAuth('/document/update')"
-                    style="font-size: 20px"
+                    style="font-size: 15px"
                     @click="Analytical(scope.row)"
                   ></el-button
                 ></el-tooltip>
@@ -185,7 +186,7 @@
                     circle
                     icon="el-icon-edit"
                     v-if="checkAuth('/document/update')"
-                    style="font-size: 20px"
+                    style="font-size: 15px"
                     @click="btnEdit(scope.row)"
                   ></el-button
                 ></el-tooltip>
@@ -202,7 +203,7 @@
                     icon="el-icon-download"
                     @click="btnDown(scope.row)"
                     :loading="scope.row.downloading"
-                    style="font-size: 20px"
+                    style="font-size: 15px"
                   ></el-button
                 ></el-tooltip>
                 <el-tooltip
@@ -218,7 +219,7 @@
                     icon="el-icon-delete"
                     v-if="checkAuth('/document/delete')"
                     @click="btnDelete(scope.row.id)"
-                    style="font-size: 20px"
+                    style="font-size: 15px"
                   ></el-button
                 ></el-tooltip>
               </div>

Some files were not shown because too many files changed in this diff