From e7a44b64dceb984b0bb243bfdcae73edb099e5f1 Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期一, 26 八月 2024 21:04:49 +0800
Subject: [PATCH] agent
---
src/views/dmx/model/components/addTableName.vue | 152 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 122 insertions(+), 30 deletions(-)
diff --git a/src/views/dmx/model/components/addTableName.vue b/src/views/dmx/model/components/addTableName.vue
index a6b5631..e560d56 100644
--- a/src/views/dmx/model/components/addTableName.vue
+++ b/src/views/dmx/model/components/addTableName.vue
@@ -2,7 +2,7 @@
<!-- 娣诲姞妯″瀷 -->
<a-modal
v-model:visible="addTabVisible"
- title="娣诲姞妯″紡"
+ :title="title"
@before-open="handleOpened"
@cancel="handleCancel"
:footer="false"
@@ -17,28 +17,48 @@
: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="name" label="妯″瀷妗嗘灦">
+ <!-- <a-input v-model="form.name" placeholder="璇疯緭鍏ユā鍨嬪悕绉�" /> -->
+ <a-select
+ v-model="form.name"
+ placeholder="璇烽�夋嫨妯″瀷妗嗘灦"
+ allow-create
+ allow-search
+ >
+ <a-option
+ v-for="(item, index) in modalList"
+ :value="item.name"
+ :label="item.name"
+ :disabled="item.added"
+ ></a-option>
+ </a-select>
</a-form-item>
- <a-form-item field="apiKey" label="API-Key">
+ <!-- <a-form-item field="apiKey" label="API-Key">
<a-input v-model="form.apiKey" placeholder="API-Key" />
</a-form-item>
<a-form-item field="baseUrl" label="Base-Url">
<a-input v-model="form.baseUrl" placeholder="Base-Url" />
- </a-form-item>
+ </a-form-item> -->
<a-form-item field="tags" label="妯″瀷鎻忚堪">
<a-textarea
v-model="form.tags"
placeholder="璇疯緭鍏ユā鍨嬫弿杩�"
+ :max-length="50"
allow-clear
/>
</a-form-item>
- <a-form-item field="section" label="妯″瀷鍥剧墖">
- <a-space direction="vertical" :style="{ width: '100%' }">
+ <a-form-item field="logo" label="妯″瀷鍥剧墖">
+ <a-space
+ v-model="form.logo"
+ direction="vertical"
+ :style="{ width: '100%' }"
+ >
<Upload
:action="uploadAction"
:limit="1"
+ :url="form.urlS"
+ @handleRemove="deleteRemove"
@update:fileList="updateFileList"
@success="handleSuccess"
></Upload>
@@ -57,11 +77,29 @@
</template>
<script lang="ts" setup>
- import { onMounted, onBeforeMount, reactive, ref, computed } from 'vue';
- import { addLlmFactory } from '@/api/model';
+ import {
+ onMounted,
+ onBeforeMount,
+ watchEffect,
+ reactive,
+ ref,
+ computed,
+ } from 'vue';
+ import {
+ getFactories,
+ addLlmFactory,
+ getLlmDetail,
+ editLlmFactory,
+ } from '@/api/model';
+
import { Message } from '@arco-design/web-vue';
+ import { userModelState } from '@/store';
+
+ const modelStore = userModelState();
const addTabVisible = defineModel('tabShow');
+
+ const httpUrl = modelStore.hrefUrl;
const loading = ref(false);
const props = defineProps({
task_id: {
@@ -71,6 +109,10 @@
nameList: {
type: Object,
default: {},
+ },
+ title: {
+ type: String,
+ default: '娣诲姞妯″瀷',
},
});
const editList = computed(() => props.nameList);
@@ -82,20 +124,27 @@
api_base: '',
tags: '',
logo: '',
+ urlS: '',
});
- const formRef = ref(null);
+ const formRef = ref();
const rules = {
name: [
{
required: true,
- message: '鍚嶇О涓嶅厑璁镐负绌�',
+ message: '妯″瀷妗嗘灦涓嶅厑璁镐负绌�',
},
],
- describe: [
+ tags: [
{
required: true,
message: '鎻忚堪涓嶅厑璁镐负绌�',
+ },
+ ],
+ logo: [
+ {
+ required: true,
+ message: '妯″瀷鍥剧墖涓嶈兘涓虹┖',
},
],
};
@@ -104,23 +153,40 @@
console.log(editList, 9999);
formRef.value.validate().then(async (res) => {
if (!res) {
- await addLlmFactory({
- name: form.name,
- tags: form.tags,
- api_base: form.api_base,
- // all_params: all_params,
- logo: imageUrls.value[0],
- })
- .then((resData) => {
- if ((resData as any).code === 200) {
- emit('refresh-parent');
- addTabVisible.value = false;
- Message.success('娣诲姞鎴愬姛');
- }
+ if (props.title == '缂栬緫妯″瀷') {
+ await editLlmFactory({
+ name: form.name,
+ tags: form.tags,
+ api_base: form.api_base,
+ // all_params: all_params,
+ logo: uploadUrl.value[0] || '',
})
- .catch(() => {
- Message.error('娣诲姞澶辫触');
- });
+ .then((resData) => {
+ if ((resData as any).code === 200) {
+ emit('refresh-parent',form.name);
+ addTabVisible.value = false;
+ }
+ })
+ .catch(() => {});
+ } else {
+ await addLlmFactory({
+ name: form.name,
+ tags: form.tags,
+ api_base: form.api_base,
+ // all_params: all_params,
+ logo: uploadUrl.value[0],
+ })
+ .then((resData) => {
+ if ((resData as any).code === 200) {
+ emit('refresh-parent', form.name);
+ addTabVisible.value = false;
+ Message.success('娣诲姞鎴愬姛');
+ }
+ })
+ .catch(() => {
+ Message.error('娣诲姞澶辫触');
+ });
+ }
}
});
};
@@ -136,13 +202,25 @@
const uploadAction = '/api/v1/llm/upload'; // 鏇挎崲涓轰綘鐨勪笂浼燗PI
const fileList = ref([]);
const imageUrls = ref([]);
+ const uploadUrl = ref([]);
const updateFileList = (newFileList) => {
fileList.value = newFileList;
};
+ const deleteRemove = () => {
+ form.logo = '';
+ uploadUrl.value = [];
+ imageUrls.value = [];
+ };
+
const handleSuccess = (urls) => {
- imageUrls.value = urls; // 鎷垮埌涓婁紶鐨勫浘鐗囧湴鍧�
- console.log(urls, 77777);
+ uploadUrl.value = urls;
+ form.logo = urls[0];
+
+ const urlsArr = urls.map((url) => {
+ return httpUrl + url;
+ });
+ imageUrls.value = urlsArr; // 鎷垮埌涓婁紶鐨勫浘鐗囧湴鍧�
};
const handleOpened = (el) => {
@@ -154,6 +232,20 @@
});
formRef.value?.resetFields();
};
+ const modalList = ref([]);
+ const queryModel = async () => {
+ const res = await getFactories();
+ modalList.value = res.data;
+ };
+ queryModel();
+
+ watchEffect(() => {
+ if (props.nameList && props.title == '缂栬緫妯″瀷') {
+ form.name = props.nameList.llm_factory;
+ form.tags = props.nameList.tags;
+ form.urlS = props.nameList.logo;
+ }
+ });
</script>
<script lang="ts">
--
Gitblit v1.8.0