Kaynağa Gözat

智能体配置页面修改

liudong 2 yıl önce
ebeveyn
işleme
bce2806ff4

+ 156 - 24
src/views/dmx/IntelligentAgent/components/agentConfig.vue

@@ -10,6 +10,8 @@
     title="智能体配置"
     title="智能体配置"
     @before-open="handleOpened"
     @before-open="handleOpened"
     @cancel="handleCancel"
     @cancel="handleCancel"
+    :ok-loading="loading"
+    @before-ok="handleBeforeOk"
     :footer="true"
     :footer="true"
     title-align="start"
     title-align="start"
     width="600px"
     width="600px"
@@ -78,7 +80,7 @@
                   </a-space>
                   </a-space>
                 </a-form-item>
                 </a-form-item>
                 <a-form-item label="空回复">
                 <a-form-item label="空回复">
-                  <a-input v-model="form.name" placeholder="" />
+                  <a-input v-model="form.prompt_config.empty_response" placeholder="" />
                 </a-form-item>
                 </a-form-item>
                 <a-form-item label="设置开场白">
                 <a-form-item label="设置开场白">
                   <a-textarea
                   <a-textarea
@@ -88,13 +90,13 @@
                   />
                   />
                 </a-form-item>
                 </a-form-item>
                 <a-form-item label="显示引文">
                 <a-form-item label="显示引文">
-                  <a-space direction="vertical" size="large">
-                    <a-switch v-model="form.layout_recognize" />
+                  <a-space direction="vertical" >
+                    <a-switch v-model="form.prompt_config.quote" size="small" />
                   </a-space>
                   </a-space>
                 </a-form-item>
                 </a-form-item>
                 <a-form-item label="Self-RAG">
                 <a-form-item label="Self-RAG">
-                  <a-space direction="vertical" size="large">
-                    <a-switch v-model="form.layout_recognize" />
+                  <a-space direction="vertical">
+                    <a-switch v-model="form.prompt_config.self_rag" size="small" />
                   </a-space>
                   </a-space>
                 </a-form-item>
                 </a-form-item>
                 <a-form-item field="kb_ids" label="知识库">
                 <a-form-item field="kb_ids" label="知识库">
@@ -127,7 +129,7 @@
             <a-divider style="margin-bottom: 20px;margin-top: 0" />
             <a-divider style="margin-bottom: 20px;margin-top: 0" />
             <a-scrollbar style="width: 100%;overflow: auto" :style="{height:height}">
             <a-scrollbar style="width: 100%;overflow: auto" :style="{height:height}">
             <a-form
             <a-form
-              ref="formRef"
+              ref="formRef1"
               :rules="rules"
               :rules="rules"
               :model="form"
               :model="form"
               @submit="handleSubmit"
               @submit="handleSubmit"
@@ -142,13 +144,13 @@
               </a-form-item>
               </a-form-item>
               <a-divider style="margin: 0;margin-bottom: 10px" />
               <a-divider style="margin: 0;margin-bottom: 10px" />
               <a-form-item  label="相似度阈值">
               <a-form-item  label="相似度阈值">
-                <a-slider :min="0" :max="100"  :format-tooltip="formatter" />
+                <a-slider v-model="form.similarity_threshold"  :step="0.01" :min="0" :max="1"  />
               </a-form-item>
               </a-form-item>
               <a-form-item  label="关键字相似度权重">
               <a-form-item  label="关键字相似度权重">
-                <a-slider :min="0" :max="100"  :format-tooltip="formatter" />
+                <a-slider v-model="form.vector_similarity_weight"  :step="0.01" :min="0" :max="1"  />
               </a-form-item>
               </a-form-item>
               <a-form-item  label="Top N">
               <a-form-item  label="Top N">
-                <a-slider :min="0" :max="30"  />
+                <a-slider v-model="form.top_n" :min="0" :max="30"  />
               </a-form-item>
               </a-form-item>
               <a-form-item label="Rerank模型" >
               <a-form-item label="Rerank模型" >
                 <a-space direction="vertical" size="large">
                 <a-space direction="vertical" size="large">
@@ -166,7 +168,7 @@
                   </a-select>
                   </a-select>
                 </a-space>
                 </a-space>
               </a-form-item>
               </a-form-item>
-              <a-form-item  label="Top-K">
+              <a-form-item v-if="form.rerank_id" label="Top-K">
                 <a-slider v-model="form.top_k" :min="1" :max="2048" />
                 <a-slider v-model="form.top_k" :min="1" :max="2048" />
               </a-form-item>
               </a-form-item>
               <a-form-item  label="变量">
               <a-form-item  label="变量">
@@ -177,7 +179,11 @@
                 </div>
                 </div>
               </a-form-item>
               </a-form-item>
               <a-form-item  label="">
               <a-form-item  label="">
-                <a-table :columns="columns" :data="form.prompt_config.parameters" style="width: 100%">
+                <a-table
+                  :columns="columns"
+                  :data="form.prompt_config.parameters"
+                  style="width: 100%"
+                >
                   <template #key="{ record }">
                   <template #key="{ record }">
                     <a-input v-model="record.key" placeholder="" />
                     <a-input v-model="record.key" placeholder="" />
                   </template>
                   </template>
@@ -185,9 +191,9 @@
                     <a-switch v-model="record.optional" size="small" />
                     <a-switch v-model="record.optional" size="small" />
                   </template>
                   </template>
                   <template #action="{ record }">
                   <template #action="{ record }">
-                    <a-button type="text" @click="handleClick" style="margin-left: 0px" size="small">
+                    <a-button type="text" @click="deleteParameters(record)" style="margin-left: 0px" size="small">
                       <template #icon>
                       <template #icon>
-                        <icon-delete />
+                        <icon-delete  />
                       </template>
                       </template>
                     </a-button>
                     </a-button>
                   </template>
                   </template>
@@ -200,15 +206,69 @@
             <a-divider style="margin-bottom: 20px;margin-top: 0" />
             <a-divider style="margin-bottom: 20px;margin-top: 0" />
             <div style="width: 100%;" :style="{height:height}">
             <div style="width: 100%;" :style="{height:height}">
               <a-form
               <a-form
-                ref="formRef"
+                ref="formRef2"
                 :rules="rules"
                 :rules="rules"
                 :model="form"
                 :model="form"
                 @submit="handleSubmit"
                 @submit="handleSubmit"
                 :style="{ width: '90%', margin: '0 auto' }"
                 :style="{ width: '90%', margin: '0 auto' }"
-                layout="vertical"
               >
               >
-                <a-form-item field="name" label="智能体名称">
-                  <a-input v-model="form.name" placeholder="请输入名称" />
+                <a-form-item field="llm_id" label="模型">
+                  <a-space direction="vertical" size="large">
+                    <a-select :size="'large'" field="llm_id" v-model="form.llm_id" style="width: 400px"  placeholder="请选择">
+                      <a-optgroup
+                        :label="index"
+                        v-for="(item, index) in modelList"
+                        :key="index"
+                      >
+                        <a-option
+                          v-for="obj in item"
+                          :key="obj.fid"
+                          :disabled="!obj.available"
+                          :value="obj.llm_id"
+                        >
+                          {{ obj.llm_name }}
+                        </a-option>
+                      </a-optgroup>
+                    </a-select>
+                  </a-space>
+                </a-form-item>
+                <a-divider style="margin-bottom: 20px;margin-top: 0" />
+                <a-form-item label="自由">
+                  <a-select default-value="2" :style="{width:'400px'}" placeholder="">
+                    <a-option value="1">即兴创作</a-option>
+                    <a-option value="2">精确</a-option>
+                    <a-option value="3">平衡</a-option>
+                  </a-select>
+                </a-form-item>
+                <a-form-item label="温度">
+                  <a-switch size="small" />
+                  <a-space direction="vertical" size="large">
+                    <a-slider v-model="form.llm_setting.temperature" :step="0.01" :min="0" :max="1" :style="{ width: '350px', marginLeft: '20px' }" show-input />
+                  </a-space>
+                </a-form-item>
+                <a-form-item label="top P">
+                  <a-switch  size="small" />
+                  <a-space direction="vertical" size="large">
+                    <a-slider v-model="form.llm_setting.top_p" :step="0.01" :min="0" :max="1"  :style="{ width: '350px', marginLeft: '20px' }" show-input />
+                  </a-space>
+                </a-form-item>
+                <a-form-item label="出席处罚">
+                  <a-switch size="small" />
+                  <a-space direction="vertical" size="large">
+                    <a-slider v-model="form.llm_setting.presence_penalty" :step="0.01" :min="0" :max="1"  :style="{ width: '350px', marginLeft: '20px' }" show-input />
+                  </a-space>
+                </a-form-item>
+                <a-form-item label="频率处罚">
+                  <a-switch size="small" />
+                  <a-space direction="vertical" size="large">
+                    <a-slider v-model="form.llm_setting.frequency_penalty" :step="0.01" :min="0" :max="1"  :style="{ width: '350px', marginLeft: '20px' }" show-input />
+                  </a-space>
+                </a-form-item>
+                <a-form-item label="最大token数">
+                  <a-switch size="small" />
+                  <a-space direction="vertical" size="large">
+                    <a-slider v-model="form.llm_setting.max_tokens"  :min="0" :max="2048"  :style="{ width: '350px', marginLeft: '20px' }" show-input />
+                  </a-space>
                 </a-form-item>
                 </a-form-item>
               </a-form>
               </a-form>
             </div>
             </div>
@@ -221,17 +281,21 @@
 
 
 <script lang="ts" setup>
 <script lang="ts" setup>
 import { onMounted, onBeforeMount, reactive, ref, nextTick } from "vue";
 import { onMounted, onBeforeMount, reactive, ref, nextTick } from "vue";
-import { queryKbList, queryModelList } from "@/api/kbList";
+import { kbdocumentupload, queryKbList, queryModelList } from "@/api/kbList";
 import useLoading from "@/hooks/loading";
 import useLoading from "@/hooks/loading";
+import { Message } from "@arco-design/web-vue";
+import { dialogSet } from "@/api/Agent";
 const { loading,setLoading } = useLoading(true);
 const { loading,setLoading } = useLoading(true);
-
+const props = defineProps(['typeAngint', 'formData']);
+const emit = defineEmits(['queryList']);
 const visible = ref(false);
 const visible = ref(false);
-const editAgentKuai = ref();
 const modelList = ref({});
 const modelList = ref({});
 const rankModelList = ref({});
 const rankModelList = ref({});
 let tabs = ref([]);
 let tabs = ref([]);
 const file = ref();
 const file = ref();
 const formRef = ref();
 const formRef = ref();
+const formRef1 = ref();
+const formRef2 = ref();
 const form = reactive({
 const form = reactive({
   name: "",
   name: "",
   icon: "",
   icon: "",
@@ -245,6 +309,7 @@ const form = reactive({
       "回答需要考虑聊天历史。\n        以下是知识库:\n        {knowledge}\n        以上是知识库。",
       "回答需要考虑聊天历史。\n        以下是知识库:\n        {knowledge}\n        以上是知识库。",
     parameters: [
     parameters: [
       {
       {
+        index: 0,
         key: "knowledge",
         key: "knowledge",
         optional: false
         optional: false
       }
       }
@@ -261,9 +326,11 @@ const form = reactive({
   },
   },
   similarity_threshold: 0.2,
   similarity_threshold: 0.2,
   vector_similarity_weight: 0.30000000000000004,
   vector_similarity_weight: 0.30000000000000004,
-  top_n: 8
+  top_n: 8,
+  rerank_id:'',
+  top_k:1024,
 });
 });
-const height = ref('calc(100vh - 560px)');
+const height = ref('calc(100vh - 520px)');
 
 
 const columns = [
 const columns = [
   {
   {
@@ -339,7 +406,7 @@ const rules = {
 const handleSubmit = ({ values, errors }) => {
 const handleSubmit = ({ values, errors }) => {
   console.log("values:", values, "\nerrors:", errors);
   console.log("values:", values, "\nerrors:", errors);
   if (!errors) {
   if (!errors) {
-    editAgentKuai.value.handleClick(form);
+
   }
   }
 };
 };
 
 
@@ -353,6 +420,8 @@ defineExpose({
 const handleCancel = () => {
 const handleCancel = () => {
   visible.value = false;
   visible.value = false;
   formRef.value.resetFields();
   formRef.value.resetFields();
+  formRef1.value.resetFields();
+  formRef2.value.resetFields();
   form.name = "";
   form.name = "";
 };
 };
 
 
@@ -367,18 +436,81 @@ const handleOpened = (el) => {
   form.name = "";
   form.name = "";
   form.prompt_config.system = "你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。" +
   form.prompt_config.system = "你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。" +
     "回答需要考虑聊天历史。\n        以下是知识库:\n        {knowledge}\n        以上是知识库。";
     "回答需要考虑聊天历史。\n        以下是知识库:\n        {knowledge}\n        以上是知识库。";
+  formRef.value.resetFields();
+  formRef1.value.resetFields();
+  formRef2.value.resetFields();
 };
 };
 
 
+
+const handleBeforeOk = async (done) => {
+  let valid = '';
+  let valid1 = '';
+  let valid2 = '';
+  formRef.value.validate().then(res => {
+    console.log('res:', res)
+    valid = res;
+  })
+  formRef1.value.validate().then(res => {
+    console.log('res:', res)
+    valid1 = res;
+  })
+  formRef2.value.validate().then(res => {
+    console.log('res:', res)
+    valid2 = res;
+  })
+  if (valid || valid1 || valid2) {
+
+    console.log('请求数据');
+    let title = '创建成功';
+    let formNew = { ...form };
+    if (props.typeAngint == 'edit') {
+      formNew.dialog_id = form.id;
+      delete formNew.id;
+      delete formNew.off;
+      title = '修改成功';
+    }
+    setLoading(true)
+    try {
+      const data = await dialogSet(formNew);
+      console.log(data.data, 'data');
+      if (data.code == 0){
+        Message.success(title);
+        handleCancel();
+        emit('queryList');
+      }else {
+        Message.error(data.msg);
+      }
+      done(true);
+    } catch (err) {
+      // you can report use errorHandler or other
+      setLoading(false)
+    }
+  }else {
+    Message.warning('请填写必填项');
+    done(false)
+  }
+};
+
+
 const addVariable = () => {
 const addVariable = () => {
   form.prompt_config.parameters.push({
   form.prompt_config.parameters.push({
+    index: form.prompt_config.parameters.length,
     key: "",
     key: "",
-    optional: false
+    optional: true
   });
   });
   nextTick(() => {
   nextTick(() => {
     formRef.value.validate();
     formRef.value.validate();
   });
   });
 }
 }
 
 
+const deleteParameters = (record) => {
+  // console.log(record, 'record');
+  // console.log(form.prompt_config.parameters);
+  form.prompt_config.parameters = form.prompt_config.parameters.filter(item => item.index !== record.index);
+
+}
+
+
 const queryModel = async (params) => {
 const queryModel = async (params) => {
   try {
   try {
     const data = await queryModelList(params);
     const data = await queryModelList(params);

+ 5 - 11
src/views/dmx/IntelligentAgent/index.vue

@@ -10,7 +10,7 @@
               style="width: 240px"
               style="width: 240px"
               @change="queryList"
               @change="queryList"
             />
             />
-            <agent></agent>
+            <agent-config typeAngint="add"></agent-config>
           </div>
           </div>
           <a-divider style="margin: 10px 0" />
           <a-divider style="margin: 10px 0" />
           <a-row justify="space-between">
           <a-row justify="space-between">
@@ -91,12 +91,12 @@
                     <div style="position: absolute; bottom: 1rem; right: 1rem">
                     <div style="position: absolute; bottom: 1rem; right: 1rem">
                       <a-space>
                       <a-space>
                         <span v-show="!item.off">
                         <span v-show="!item.off">
-                          <editAgent
+                          <agent-config
                             ref="editAgentKuai"
                             ref="editAgentKuai"
                             typeAngint="edit"
                             typeAngint="edit"
                             :formData="form"
                             :formData="form"
-                            @cancelModal="handleCancel"
-                          ></editAgent>
+                            @queryList="queryList"
+                          ></agent-config>
                         </span>
                         </span>
                         <a-popconfirm
                         <a-popconfirm
                           :content="'确定删除吗'"
                           :content="'确定删除吗'"
@@ -124,15 +124,12 @@
 
 
 <script lang="ts" setup>
 <script lang="ts" setup>
 import { ref, reactive, nextTick, onBeforeMount, onMounted, onBeforeUnmount } from "vue";
 import { ref, reactive, nextTick, onBeforeMount, onMounted, onBeforeUnmount } from "vue";
-  import addAgent from '@/views/dmx/IntelligentAgent/components/addAgent.vue';
-  import editAgent from '@/views/dmx/IntelligentAgent/components/editAgent.vue';
-  import agent  from "@/views/dmx/IntelligentAgent/components/agentConfig.vue";
-  import { kbdocumentrm, queryKbList } from '@/api/kbList';
   import { Message } from '@arco-design/web-vue';
   import { Message } from '@arco-design/web-vue';
   import { deletedialog, querydialogList } from '@/api/Agent';
   import { deletedialog, querydialogList } from '@/api/Agent';
   import useLoading from '@/hooks/loading';
   import useLoading from '@/hooks/loading';
   const { loading, setLoading } = useLoading(true);
   const { loading, setLoading } = useLoading(true);
   import EventBus from '@/utils/EventBus';
   import EventBus from '@/utils/EventBus';
+  import AgentConfig from "@/views/dmx/IntelligentAgent/components/agentConfig.vue";
 
 
   let count = 5;
   let count = 5;
   const activeKey = ref(1);
   const activeKey = ref(1);
@@ -161,9 +158,6 @@ import { ref, reactive, nextTick, onBeforeMount, onMounted, onBeforeUnmount } fr
   const handleAdd = () => {
   const handleAdd = () => {
     addAgents.value.handleClick();
     addAgents.value.handleClick();
   };
   };
-  const handleDelete = (key: any) => {
-    data.value = data.value.filter((item) => item.key !== key);
-  };
 
 
   const visible = ref(false);
   const visible = ref(false);
   const formRef = ref(null);
   const formRef = ref(null);

+ 3 - 1
src/views/dmx/knowledgeLib/index.vue

@@ -54,7 +54,9 @@
                             @change="search"
                             @change="search"
                           />
                           />
                           <!--新建-->
                           <!--新建-->
-                          <add :kbobj="kbobj" @changeFetchData="changeFetchData"/>
+                          <span v-if="tabs.length > 0">
+                            <add :kbobj="kbobj" @changeFetchData="changeFetchData"/>
+                          </span>
                         </a-col>
                         </a-col>
                       </a-row>
                       </a-row>
                     </a-form>
                     </a-form>