From 602669635bc2befb52370f0f24c448fccab014c7 Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期三, 07 八月 2024 18:45:28 +0800
Subject: [PATCH] 配置bug页面修改
---
src/views/dmx/IntelligentAgent/components/agentConfig.vue | 220 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 190 insertions(+), 30 deletions(-)
diff --git a/src/views/dmx/IntelligentAgent/components/agentConfig.vue b/src/views/dmx/IntelligentAgent/components/agentConfig.vue
index 135cd33..ff93fc2 100644
--- a/src/views/dmx/IntelligentAgent/components/agentConfig.vue
+++ b/src/views/dmx/IntelligentAgent/components/agentConfig.vue
@@ -1,22 +1,38 @@
<template>
- <a-button type="primary" @click="handleClick" style="margin-left: 10px">
+ <a-button
+ v-if="typeAngint == 'add'"
+ type="primary"
+ @click="handleClick"
+ style="margin-left: 10px">
<template #icon>
<icon-plus />
</template>
鏂板缓鏅鸿兘浣�
+ </a-button>
+ <a-button
+ v-if="typeAngint == 'edit'"
+ type="text"
+ size="small"
+ @click="editClick"
+ >
+ <template #icon>
+ <icon-tool />
+ </template>
</a-button>
<a-modal
v-model:visible="visible"
title="鏅鸿兘浣撻厤缃�"
@before-open="handleOpened"
@cancel="handleCancel"
+ :ok-loading="loading"
+ @before-ok="handleBeforeOk"
:footer="true"
title-align="start"
width="600px"
>
<a-row class="">
<a-col :span="24">
- <a-tabs type="capsule" size="large">
+ <a-tabs type="capsule" size="large" v-model="keyLarge" @tab-click="console.log(keyLarge)">
<a-tab-pane key="1" title="鍔╃悊璁剧疆">
<a-divider style="margin-bottom: 20px;margin-top: 0" />
<div style="width: 100%;" :style="{height:height}">
@@ -78,7 +94,7 @@
</a-space>
</a-form-item>
<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 label="璁剧疆寮�鍦虹櫧">
<a-textarea
@@ -88,13 +104,13 @@
/>
</a-form-item>
<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-form-item>
<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-form-item>
<a-form-item field="kb_ids" label="鐭ヨ瘑搴�">
@@ -127,7 +143,7 @@
<a-divider style="margin-bottom: 20px;margin-top: 0" />
<a-scrollbar style="width: 100%;overflow: auto" :style="{height:height}">
<a-form
- ref="formRef"
+ ref="formRef1"
:rules="rules"
:model="form"
@submit="handleSubmit"
@@ -142,13 +158,13 @@
</a-form-item>
<a-divider style="margin: 0;margin-bottom: 10px" />
<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 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 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 label="Rerank妯″瀷" >
<a-space direction="vertical" size="large">
@@ -166,7 +182,7 @@
</a-select>
</a-space>
</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-form-item>
<a-form-item label="鍙橀噺">
@@ -177,7 +193,11 @@
</div>
</a-form-item>
<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 }">
<a-input v-model="record.key" placeholder="" />
</template>
@@ -185,9 +205,9 @@
<a-switch v-model="record.optional" size="small" />
</template>
<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>
- <icon-delete />
+ <icon-delete />
</template>
</a-button>
</template>
@@ -200,15 +220,69 @@
<a-divider style="margin-bottom: 20px;margin-top: 0" />
<div style="width: 100%;" :style="{height:height}">
<a-form
- ref="formRef"
+ ref="formRef2"
:rules="rules"
:model="form"
@submit="handleSubmit"
: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="鏈�澶oken鏁�">
+ <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>
</div>
@@ -221,17 +295,21 @@
<script lang="ts" setup>
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 { Message } from "@arco-design/web-vue";
+import { dialogSet } from "@/api/Agent";
+import EventBus from "@/utils/EventBus";
const { loading,setLoading } = useLoading(true);
-
const visible = ref(false);
-const editAgentKuai = ref();
const modelList = ref({});
const rankModelList = ref({});
let tabs = ref([]);
const file = ref();
const formRef = ref();
+const formRef1 = ref();
+const formRef2 = ref();
+const keyLarge = ref('1');
const form = reactive({
name: "",
icon: "",
@@ -245,6 +323,7 @@
"鍥炵瓟闇�瑕佽�冭檻鑱婂ぉ鍘嗗彶銆俓n 浠ヤ笅鏄煡璇嗗簱锛歕n {knowledge}\n 浠ヤ笂鏄煡璇嗗簱銆�",
parameters: [
{
+ index: 0,
key: "knowledge",
optional: false
}
@@ -261,10 +340,13 @@
},
similarity_threshold: 0.2,
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(500px)');
+const props = defineProps(['typeAngint', 'formData']);
+const emit = defineEmits(['queryList']);
const columns = [
{
title: '鍏抽敭瀛�',
@@ -339,7 +421,7 @@
const handleSubmit = ({ values, errors }) => {
console.log("values:", values, "\nerrors:", errors);
if (!errors) {
- editAgentKuai.value.handleClick(form);
+
}
};
@@ -353,7 +435,10 @@
const handleCancel = () => {
visible.value = false;
formRef.value.resetFields();
+ formRef1.value.resetFields();
+ formRef2.value.resetFields();
form.name = "";
+ emit('queryList');
};
const handleOpened = (el) => {
@@ -364,21 +449,96 @@
// txt: '',// 澶囨敞
// });
formRef.value.resetFields();
- form.name = "";
- form.prompt_config.system = "浣犳槸涓�涓櫤鑳藉姪鎵嬶紝璇锋�荤粨鐭ヨ瘑搴撶殑鍐呭鏉ュ洖绛旈棶棰橈紝璇峰垪涓剧煡璇嗗簱涓殑鏁版嵁璇︾粏鍥炵瓟銆傚綋鎵�鏈夌煡璇嗗簱鍐呭閮戒笌闂鏃犲叧鏃讹紝浣犵殑鍥炵瓟蹇呴』鍖呮嫭鈥滅煡璇嗗簱涓湭鎵惧埌鎮ㄨ鐨勭瓟妗堬紒鈥濊繖鍙ヨ瘽銆�" +
- "鍥炵瓟闇�瑕佽�冭檻鑱婂ぉ鍘嗗彶銆俓n 浠ヤ笅鏄煡璇嗗簱锛歕n {knowledge}\n 浠ヤ笂鏄煡璇嗗簱銆�";
+ formRef1.value.resetFields();
+ formRef2.value.resetFields();
+
+ if(props.typeAngint=='add'){
+ form.name = "";
+ form.prompt_config.system = "浣犳槸涓�涓櫤鑳藉姪鎵嬶紝璇锋�荤粨鐭ヨ瘑搴撶殑鍐呭鏉ュ洖绛旈棶棰橈紝璇峰垪涓剧煡璇嗗簱涓殑鏁版嵁璇︾粏鍥炵瓟銆傚綋鎵�鏈夌煡璇嗗簱鍐呭閮戒笌闂鏃犲叧鏃讹紝浣犵殑鍥炵瓟蹇呴』鍖呮嫭鈥滅煡璇嗗簱涓湭鎵惧埌鎮ㄨ鐨勭瓟妗堬紒鈥濊繖鍙ヨ瘽銆�" +
+ "鍥炵瓟闇�瑕佽�冭檻鑱婂ぉ鍘嗗彶銆俓n 浠ヤ笅鏄煡璇嗗簱锛歕n {knowledge}\n 浠ヤ笂鏄煡璇嗗簱銆�";
+ }
+
+};
+
+
+const handleBeforeOk = async (done) => {
+ formRef.value.validate().then(res => {
+ // console.log('res:', res)
+ })
+ formRef1.value.validate().then(res => {
+ // console.log('res:', res)
+ })
+ formRef2.value.validate().then(res => {
+ // console.log('res:', res)
+ })
+ if (form.name && form.kb_ids.length>0 && form.prompt_config.system && form.llm_id) {
+ let title = '鍒涘缓鎴愬姛';
+ let formNew = { ...form };
+ if(formNew.rerank_id){
+ delete formNew.top_k;
+ }
+
+ if(formNew.rerank_id){
+ delete formNew.top_k;
+ }
+
+ 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');
+ if (data.code == 0){
+ Message.success(title);
+ handleCancel();
+ EventBus.emit('queryList');
+ }else {
+ Message.error(data.msg);
+ }
+ done(true);
+ setLoading(false)
+ } catch (err) {
+ // you can report use errorHandler or other
+ setLoading(false)
+ }
+ }else {
+ Message.warning('璇峰~鍐欏繀濉」');
+ done(false)
+ }
+};
+
+const editClick = (data) => {
+ visible.value = true;
+ nextTick(()=>{
+ console.log(props.formData,'浼犲叆鏁版嵁');
+ Object.assign(form, props.formData);
+ console.log(form,'琛ㄥ崟鏁版嵁');
+ })
};
const addVariable = () => {
form.prompt_config.parameters.push({
+ index: form.prompt_config.parameters.length,
key: "",
- optional: false
+ optional: true
});
nextTick(() => {
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) => {
try {
const data = await queryModelList(params);
--
Gitblit v1.8.0