| | |
| | | <!-- 添加模型 --> |
| | | <a-modal |
| | | v-model:visible="addTabVisible" |
| | | title="添加模式" |
| | | :title="title" |
| | | @before-open="handleOpened" |
| | | @cancel="handleCancel" |
| | | :footer="false" |
| | |
| | | :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="index" |
| | | :label="index" |
| | | :disabled="item.added" |
| | | ></a-option> |
| | | </a-select> |
| | | </a-form-item> |
| | | <!-- <a-form-item field="apiKey" label="API-Key"> |
| | | <a-input v-model="form.apiKey" placeholder="API-Key" /> |
| | |
| | | /> |
| | | </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> |
| | |
| | | ref, |
| | | computed, |
| | | } from 'vue'; |
| | | import { addLlmFactory, getLlmDetail } from '@/api/model'; |
| | | import { |
| | | modelmyLlms, |
| | | 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: { |
| | |
| | | nameList: { |
| | | type: Object, |
| | | default: {}, |
| | | }, |
| | | title: { |
| | | type: String, |
| | | default: '添加模型', |
| | | }, |
| | | }); |
| | | const editList = computed(() => props.nameList); |
| | |
| | | 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: '模型图片不能为空', |
| | | }, |
| | | ], |
| | | }; |
| | |
| | | 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'); |
| | | 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'); |
| | | addTabVisible.value = false; |
| | | Message.success('添加成功'); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | Message.error('添加失败'); |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | |
| | | const uploadAction = '/api/v1/llm/upload'; // 替换为你的上传API |
| | | 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) => { |
| | |
| | | }); |
| | | formRef.value?.resetFields(); |
| | | }; |
| | | |
| | | // onMounted(() => { |
| | | // if (editList.value) { |
| | | // getDetail(); |
| | | // } |
| | | // }); |
| | | |
| | | // const getDetail = async () => { |
| | | // const data = await getLlmDetail( |
| | | // editList.value.llm_factory, |
| | | // editList.value.tags |
| | | // ); |
| | | |
| | | // form.urlS = data.data.urlS; |
| | | // imageUrls.value = data.data.logo; |
| | | // }; |
| | | const modalList = ref([]); |
| | | const queryModel = async () => { |
| | | const res = await modelmyLlms(); |
| | | modalList.value = res.data; |
| | | }; |
| | | queryModel(); |
| | | |
| | | watchEffect(() => { |
| | | if (props.nameList) { |
| | | console.log(props.nameList); |
| | | if (props.nameList && props.title == '编辑模型') { |
| | | form.name = props.nameList.llm_factory; |
| | | form.tags = props.nameList.tags; |
| | | form.urlS = props.nameList.logo; |
| | | } |
| | | |
| | | // getDetail(); |
| | | }); |
| | | </script> |
| | | |