| | |
| | | <!-- 添加模型 --> |
| | | <a-modal |
| | | v-model:visible="addTabVisible" |
| | | title="添加模式" |
| | | :title="title" |
| | | @before-open="handleOpened" |
| | | @cancel="handleCancel" |
| | | :footer="false" |
| | |
| | | <a-form-item field="name" label="模型名称"> |
| | | <a-input v-model="form.name" placeholder="请输入模型名称" /> |
| | | </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" |
| | |
| | | <Upload |
| | | :action="uploadAction" |
| | | :limit="1" |
| | | :url="form.urlS" |
| | | @update:fileList="updateFileList" |
| | | @success="handleSuccess" |
| | | ></Upload> |
| | |
| | | </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 { addLlmFactory, getLlmDetail, editLlmFactory } from '@/api/model'; |
| | | import { Message } from '@arco-design/web-vue'; |
| | | |
| | | const addTabVisible = defineModel('tabShow'); |
| | |
| | | type: Object, |
| | | default: {}, |
| | | }, |
| | | title: { |
| | | type: String, |
| | | default: '添加模型', |
| | | }, |
| | | }); |
| | | const editList = computed(() => props.nameList); |
| | | |
| | |
| | | api_base: '', |
| | | tags: '', |
| | | logo: '', |
| | | urlS: '', |
| | | }); |
| | | const formRef = ref(null); |
| | | |
| | |
| | | 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: imageUrls.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: imageUrls.value[0], |
| | | }) |
| | | .then((resData) => { |
| | | if ((resData as any).code === 200) { |
| | | emit('refresh-parent'); |
| | | addTabVisible.value = false; |
| | | Message.success('添加成功'); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | Message.error('添加失败'); |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | |
| | | }); |
| | | formRef.value?.resetFields(); |
| | | }; |
| | | |
| | | 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"> |