liudong
2024-08-12 a53981aea70d2247120954a96f9f462c6bad936b
src/views/dmx/IntelligentAgent/components/agentConfig.vue
@@ -49,9 +49,10 @@
                <a-form-item label="智能体图标">
                  <a-space direction="vertical" :style="{ width: '100%' }">
                    <Upload
                      v-if="avatarShow"
                      :action="uploadAction"
                      :limit="1"
                      :url="form.icon"
                      :url="form.icon ? httpUrl + form.icon : ''"
                      @update:fileList="updateFileList"
                      @success="handleSuccess"
                    ></Upload>
@@ -162,8 +163,8 @@
                  :data="form.prompt_config.parameters"
                  style="width: 100%"
                >
                  <template #key="{ record, rowIndex }">
                    <a-input v-model="record.key" placeholder="" />
                  <template #name="{ record, rowIndex }">
                    <a-input v-model="record.name" placeholder="" />
<!--                    <a-input v-model="form.prompt_config.parameters[rowIndex].key" />-->
                  </template>
                  <template #optional="{ record }">
@@ -222,31 +223,31 @@
                <a-form-item label="温度">
                  <a-switch size="small" v-model="temperature" />
                  <a-space direction="vertical" size="large">
                    <a-slider :disabled="!temperature" v-model="form.llm_setting.temperature" :step="0.01" :min="0" :max="1" :style="{ width: '350px', marginLeft: '20px' }" show-input />
                    <a-slider :disabled="!temperature" v-model="form.llm_setting.temperature" :step="0.01" :min="0" :max="1" :style="{ width: '350px', marginLeft: '20px',display: 'flex' }" show-input />
                  </a-space>
                </a-form-item>
                <a-form-item label="top P">
                  <a-switch  size="small" v-model="top_p"  />
                  <a-space direction="vertical" size="large">
                    <a-slider :disabled="!top_p" v-model="form.llm_setting.top_p" :step="0.01" :min="0" :max="1"  :style="{ width: '350px', marginLeft: '20px' }" show-input />
                    <a-slider :disabled="!top_p" v-model="form.llm_setting.top_p" :step="0.01" :min="0" :max="1"  :style="{ width: '350px', marginLeft: '20px',display: 'flex' }" show-input />
                  </a-space>
                </a-form-item>
                <a-form-item label="出席处罚">
                  <a-switch size="small" v-model="presence_penalty"  />
                  <a-space direction="vertical" size="large">
                    <a-slider :disabled="!presence_penalty" v-model="form.llm_setting.presence_penalty" :step="0.01" :min="0" :max="1"  :style="{ width: '350px', marginLeft: '20px' }" show-input />
                    <a-slider :disabled="!presence_penalty" v-model="form.llm_setting.presence_penalty" :step="0.01" :min="0" :max="1"  :style="{ width: '350px', marginLeft: '20px',display: 'flex' }" show-input />
                  </a-space>
                </a-form-item>
                <a-form-item label="频率处罚">
                  <a-switch size="small" v-model="frequency_penalty"  />
                  <a-space direction="vertical" size="large">
                    <a-slider :disabled="!frequency_penalty" v-model="form.llm_setting.frequency_penalty" :step="0.01" :min="0" :max="1"  :style="{ width: '350px', marginLeft: '20px' }" show-input />
                    <a-slider :disabled="!frequency_penalty" v-model="form.llm_setting.frequency_penalty" :step="0.01" :min="0" :max="1"  :style="{ width: '350px', marginLeft: '20px',display: 'flex' }" show-input />
                  </a-space>
                </a-form-item>
                <a-form-item label="最大token数">
                  <a-switch size="small" v-model="max_tokens"  />
                  <a-space direction="vertical" size="large">
                    <a-slider :disabled="!max_tokens" v-model="form.llm_setting.max_tokens"  :min="0" :max="2048"  :style="{ width: '350px', marginLeft: '20px' }" show-input />
                    <a-slider :disabled="!max_tokens" v-model="form.llm_setting.max_tokens"  :min="0" :max="2048"  :style="{ width: '350px', marginLeft: '20px',display: 'flex' }" show-input />
                  </a-space>
                </a-form-item>
              </a-form>
@@ -259,7 +260,7 @@
</template>
<script lang="ts" setup>
import { onMounted, onBeforeMount, reactive, ref, nextTick } from "vue";
import { onMounted, onBeforeMount, reactive, ref, nextTick, onUnmounted, onBeforeUnmount } from "vue";
import { kbdocumentupload, queryKbList, queryModelList } from "@/api/kbList";
import useLoading from "@/hooks/loading";
import { Message } from "@arco-design/web-vue";
@@ -289,6 +290,7 @@
    parameters: [
      {
        index: 0,
        name: "knowledge",
        key: "knowledge",
        optional: false
      }
@@ -314,7 +316,8 @@
let presence_penalty = ref(true);
let frequency_penalty = ref(true);
let max_tokens = ref(true);
const httpUrl = localStorage.getItem('httpUrl');
let avatarShow = ref(true);
const height = ref('calc(500px)');
const props = defineProps(['typeAngint', 'formData']);
@@ -322,8 +325,8 @@
const columns = [
  {
    title: '关键字',
    dataIndex: 'key',
    slotName: 'key',
    dataIndex: 'name',
    slotName: 'name',
  },
  {
    title: '可选',
@@ -416,13 +419,20 @@
  formRef.value.resetFields();
  formRef1.value.resetFields();
  formRef2.value.resetFields();
  nextTick(()=>{
    if(props.typeAngint=='add'){
      form.name = "";
      form.icon = "";
      form.prompt_config.system = "你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。" +
        "回答需要考虑聊天历史。\n        以下是知识库:\n        {knowledge}\n        以上是知识库。";
  if(props.typeAngint=='add'){
    form.name = "";
    form.prompt_config.system = "你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。" +
      "回答需要考虑聊天历史。\n        以下是知识库:\n        {knowledge}\n        以上是知识库。";
  }
    }
    console.log(form,'新建智能体弹窗');
    avatarShow.value = false;
    setTimeout(() => {
      avatarShow.value = true;
    },100);
  })
};
@@ -446,6 +456,15 @@
    if(formNew.rerank_id){
      delete formNew.top_k;
    }
    formNew.prompt_config.parameters = form.prompt_config.parameters.map(item => {
      return {
        ...item,
        key: item.name
      }
    })
    console.log(formNew,'formNew');
    if (props.typeAngint == 'edit') {
      formNew.dialog_id = form.id;
@@ -489,6 +508,7 @@
  form.prompt_config.parameters.push({
    index: form.prompt_config.parameters.length,
    key: "",
    name: "",
    optional: true
  });
  nextTick(() => {
@@ -505,7 +525,6 @@
function handleTabChange(key) {
  // 处理标签改变事件
  console.log('Changed to tab:', key);
  activeKey.value=key;
}
@@ -549,6 +568,11 @@
onMounted(() => {});
onBeforeUnmount(()=>{
})
</script>