From 9cf32f84934cf13dba77e20fdddf8703e11b0c62 Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期二, 13 八月 2024 20:04:20 +0800
Subject: [PATCH] agent会话开发
---
src/views/dmx/IntelligentAgent/components/agentConfig.vue | 176 ++++++++++++++++++++++++++++------------------------------
1 files changed, 85 insertions(+), 91 deletions(-)
diff --git a/src/views/dmx/IntelligentAgent/components/agentConfig.vue b/src/views/dmx/IntelligentAgent/components/agentConfig.vue
index ff93fc2..2c6c42f 100644
--- a/src/views/dmx/IntelligentAgent/components/agentConfig.vue
+++ b/src/views/dmx/IntelligentAgent/components/agentConfig.vue
@@ -32,7 +32,7 @@
>
<a-row class="">
<a-col :span="24">
- <a-tabs type="capsule" size="large" v-model="keyLarge" @tab-click="console.log(keyLarge)">
+ <a-tabs type="capsule" size="large" :active-key="activeKey" @change="handleTabChange">
<a-tab-pane key="1" title="鍔╃悊璁剧疆">
<a-divider style="margin-bottom: 20px;margin-top: 0" />
<div style="width: 100%;" :style="{height:height}">
@@ -48,49 +48,14 @@
</a-form-item>
<a-form-item label="鏅鸿兘浣撳浘鏍�">
<a-space direction="vertical" :style="{ width: '100%' }">
- <a-upload
- :auto-upload="false"
- :fileList="file ? [file] : []"
- :show-file-list="false"
- @change="onChange"
- @progress="onProgress"
- >
- <template #upload-button>
- <div
- :class="`arco-upload-list-item${
- file && file.status === 'error' ? ' arco-upload-list-item-error' : ''
- }`"
- >
- <div
- class="arco-upload-list-picture custom-upload-avatar"
- v-if="file && file.url"
- >
- <img :src="file.url" />
- <div class="arco-upload-list-picture-mask">
- <IconEdit />
- </div>
- <a-progress
- v-if="file.status === 'uploading' && file.percent < 100"
- :percent="file.percent"
- type="circle"
- size="mini"
- :style="{
- position: 'absolute',
- left: '50%',
- top: '50%',
- transform: 'translateX(-50%) translateY(-50%)',
- }"
- />
- </div>
- <div class="arco-upload-picture-card" v-else>
- <div class="arco-upload-picture-card-text">
- <IconPlus />
- <div style="margin-top: 10px; font-weight: 600">涓婁紶</div>
- </div>
- </div>
- </div>
- </template>
- </a-upload>
+ <Upload
+ v-if="avatarShow"
+ :action="uploadAction"
+ :limit="1"
+ :url="form.icon ? httpUrl + form.icon : ''"
+ @update:fileList="updateFileList"
+ @success="handleSuccess"
+ ></Upload>
</a-space>
</a-form-item>
<a-form-item label="绌哄洖澶�">
@@ -198,14 +163,15 @@
:data="form.prompt_config.parameters"
style="width: 100%"
>
- <template #key="{ record }">
- <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 }">
<a-switch v-model="record.optional" size="small" />
</template>
<template #action="{ record }">
- <a-button type="text" @click="deleteParameters(record)" style="margin-left: 0px" size="small">
+ <a-button type="text" @click="deleteParameters(record)" style="margin-left: 0" size="small">
<template #icon>
<icon-delete />
</template>
@@ -255,33 +221,33 @@
</a-select>
</a-form-item>
<a-form-item label="娓╁害">
- <a-switch size="small" />
+ <a-switch size="small" v-model="temperature" />
<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-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" />
+ <a-switch size="small" v-model="top_p" />
<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-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" />
+ <a-switch size="small" v-model="presence_penalty" />
<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-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" />
+ <a-switch size="small" v-model="frequency_penalty" />
<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-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="鏈�澶oken鏁�">
- <a-switch size="small" />
+ <a-switch size="small" v-model="max_tokens" />
<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-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>
@@ -294,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";
@@ -309,7 +275,7 @@
const formRef = ref();
const formRef1 = ref();
const formRef2 = ref();
-const keyLarge = ref('1');
+const activeKey = ref('1');
const form = reactive({
name: "",
icon: "",
@@ -318,12 +284,13 @@
empty_response: "",
prologue: "浣犲ソ锛� 鎴戞槸浣犵殑鍔╃悊锛屾湁浠�涔堝彲浠ュ府鍒颁綘鐨勫悧锛�",
quote: true,
- self_rag: true,
+ self_rag: false,
system: "浣犳槸涓�涓櫤鑳藉姪鎵嬶紝璇锋�荤粨鐭ヨ瘑搴撶殑鍐呭鏉ュ洖绛旈棶棰橈紝璇峰垪涓剧煡璇嗗簱涓殑鏁版嵁璇︾粏鍥炵瓟銆傚綋鎵�鏈夌煡璇嗗簱鍐呭閮戒笌闂鏃犲叧鏃讹紝浣犵殑鍥炵瓟蹇呴』鍖呮嫭鈥滅煡璇嗗簱涓湭鎵惧埌鎮ㄨ鐨勭瓟妗堬紒鈥濊繖鍙ヨ瘽銆�" +
"鍥炵瓟闇�瑕佽�冭檻鑱婂ぉ鍘嗗彶銆俓n 浠ヤ笅鏄煡璇嗗簱锛歕n {knowledge}\n 浠ヤ笂鏄煡璇嗗簱銆�",
parameters: [
{
index: 0,
+ name: "knowledge",
key: "knowledge",
optional: false
}
@@ -344,14 +311,22 @@
rerank_id:'',
top_k:1024,
});
+let temperature = ref(true);
+let top_p = ref(true);
+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']);
const emit = defineEmits(['queryList']);
const columns = [
{
title: '鍏抽敭瀛�',
- dataIndex: 'key',
- slotName: 'key',
+ dataIndex: 'name',
+ slotName: 'name',
},
{
title: '鍙��',
@@ -369,26 +344,18 @@
return `${(value / 100).toFixed(2)}`
};
-const onChange = (_, currentFile) => {
- file.value = currentFile;
- convertImageToBase64(file.value.file).then((result) => {
- form.icon = result;
- });
+const uploadAction = '/api/v1/llm/upload'; // 鏇挎崲涓轰綘鐨勪笂浼燗PI
+const fileList = ref([]);
+const imageUrls = ref([]);
+
+const updateFileList = (newFileList) => {
+ fileList.value = newFileList;
+ console.log(newFileList, 88);
};
-function convertImageToBase64(file) {
- return new Promise((resolve, reject) => {
- const reader = new FileReader();
- reader.onloadend = function() {
- resolve(reader.result);
- };
- reader.onerror = reject;
- reader.readAsDataURL(file);
- });
-}
-
-const onProgress = (currentFile) => {
- file.value = currentFile;
+const handleSuccess = (urls) => {
+ imageUrls.value = urls; // 鎷垮埌涓婁紶鐨勫浘鐗囧湴鍧�
+ form.icon = urls[0];
};
const rules = {
@@ -448,16 +415,24 @@
// post: '',// 宀椾綅
// txt: '',// 澶囨敞
// });
+ activeKey.value= '1'
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);
+ })
};
@@ -482,6 +457,15 @@
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;
delete formNew.id;
@@ -491,7 +475,7 @@
setLoading(true)
try {
const data = await dialogSet(formNew);
- console.log(data, 'data');
+ // console.log(data, 'data');
if (data.code == 0){
Message.success(title);
handleCancel();
@@ -514,7 +498,7 @@
const editClick = (data) => {
visible.value = true;
nextTick(()=>{
- console.log(props.formData,'浼犲叆鏁版嵁');
+ // console.log(props.formData,'浼犲叆鏁版嵁');
Object.assign(form, props.formData);
console.log(form,'琛ㄥ崟鏁版嵁');
})
@@ -524,6 +508,7 @@
form.prompt_config.parameters.push({
index: form.prompt_config.parameters.length,
key: "",
+ name: "",
optional: true
});
nextTick(() => {
@@ -538,11 +523,15 @@
}
+function handleTabChange(key) {
+ // 澶勭悊鏍囩鏀瑰彉浜嬩欢
+ activeKey.value=key;
+}
const queryModel = async (params) => {
try {
const data = await queryModelList(params);
- console.log(data.data, '澶фā鍨嬪垪琛�');
+ // console.log(data.data, '澶фā鍨嬪垪琛�');
modelList.value = data.data;
rankModelList.value = {
BAAI: [data.data.BAAI[1]],
@@ -560,10 +549,10 @@
setLoading(true);
try {
const { data } = await queryKbList(params);
- console.log(data, 'data');
+ // console.log(data, 'data');
nextTick(() => {
tabs.value = data;
- console.log(tabs.value, 'tabs');
+ // console.log(tabs.value, 'tabs');
});
} catch (err) {
// you can report use errorHandler or other
@@ -579,6 +568,11 @@
onMounted(() => {});
+onBeforeUnmount(()=>{
+
+})
+
+
</script>
--
Gitblit v1.8.0