index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <template>
  2. <div class="container">
  3. <Breadcrumb :items="['大模型', '模型管理']" />
  4. <a-row :gutter="20" align="stretch">
  5. <a-col :span="24">
  6. <a-card
  7. class="general-card"
  8. style="min-height: 130px"
  9. :title="$t('大模型管理')"
  10. >
  11. <a-row justify="space-between">
  12. <a-col :span="24" class="table_add_clore" v-if="loading">
  13. <a-tabs
  14. :default-active-key="tabKey"
  15. type="line"
  16. :editable="true"
  17. @tab-click="changeTabs"
  18. @add="handleAdd"
  19. @delete="handleDelete"
  20. show-add-button
  21. auto-switch
  22. >
  23. <a-tab-pane
  24. v-for="(item, index) in tabData"
  25. :key="index"
  26. :title="index"
  27. :closable="Object.keys(tabData).length >= 4"
  28. >
  29. <div
  30. style="display: flex; flex-wrap: wrap"
  31. class="card_content"
  32. >
  33. <div class="card-wrap">
  34. <div class="card_wrap_box">
  35. <div class="card_wrap_box_img">
  36. <img
  37. :style="{
  38. width: '100%',
  39. }"
  40. alt="暂无图片"
  41. :src="item.logo"
  42. />
  43. </div>
  44. <a-card :bordered="false" hoverable>
  45. <div class="arco-card-body-content">
  46. <div
  47. class="arco-card-body-content-title"
  48. style="word-wrap: break-word"
  49. >
  50. {{ item.tags }}
  51. </div>
  52. <!-- <div class="arco-card-body-content-dec">{{
  53. list.type
  54. }}</div> -->
  55. </div>
  56. </a-card>
  57. <div class="arco-btn-group">
  58. <a-space class="btn-group">
  59. <!-- <editModel></editModel> -->
  60. <a-button
  61. type="primary"
  62. @click="handleEditModel(item, 1)"
  63. >
  64. 编辑
  65. </a-button>
  66. </a-space>
  67. </div>
  68. </div>
  69. </div>
  70. <div
  71. class="card-wrap"
  72. v-for="(list, index) of item.llm"
  73. :key="index"
  74. >
  75. <div class="card_wrap_box">
  76. <div class="card_wrap_box_img">
  77. <img
  78. :style="{
  79. width: '100%',
  80. }"
  81. alt="暂无图片"
  82. :src="list.logo"
  83. />
  84. <!-- src="https://p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/a20012a2d4d5b9db43dfc6a01fe508c0.png~tplv-uwbnlip3yd-webp.webp" -->
  85. </div>
  86. <a-card :bordered="false" hoverable>
  87. <div class="arco-card-body-content">
  88. <div class="arco-card-body-content-title">
  89. {{ list.name }}
  90. </div>
  91. <div class="arco-card-body-content-dec">{{
  92. list.type
  93. }}</div>
  94. </div>
  95. </a-card>
  96. <div class="arco-btn-group">
  97. <a-space class="btn-group">
  98. <a-button @click="handleDeleteModel(list)">
  99. 删除
  100. </a-button>
  101. <a-button
  102. type="primary"
  103. @click="handleEditModel(list)"
  104. >
  105. 编辑
  106. </a-button>
  107. <!-- <editModel></editModel> -->
  108. </a-space>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </a-tab-pane>
  114. </a-tabs>
  115. </a-col>
  116. <div> </div>
  117. <div class="box_right">
  118. <!-- <div class="search_input">
  119. <a-input-search
  120. :placeholder="$t('cardList.searchInput.placeholder')"
  121. style="width: 240px"
  122. />
  123. </div> -->
  124. <div>
  125. <!-- <addModel></addModel> -->
  126. <a-button
  127. type="primary"
  128. :loading="loading2"
  129. @click="handleAddModel"
  130. >
  131. <template #icon>
  132. <icon-plus />
  133. </template>
  134. 添加
  135. </a-button>
  136. </div>
  137. </div>
  138. </a-row>
  139. </a-card>
  140. </a-col>
  141. </a-row>
  142. <!-- 添加模型 -->
  143. <addPageModel
  144. v-model:show="show"
  145. :task_id="task_id"
  146. :type="modelType"
  147. :title="title"
  148. :editList="editList"
  149. @refresh-parent="refreshParentMethod"
  150. v-if="show"
  151. ></addPageModel>
  152. <!-- 添加tab模式 -->
  153. <addTableName
  154. v-model:tabShow="tabShow"
  155. :nameList="editList"
  156. :title="title"
  157. @refresh-parent="refreshParentMethod"
  158. v-if="tabShow"
  159. ></addTableName>
  160. </div>
  161. </template>
  162. <script lang="ts" setup>
  163. import { ref, reactive, nextTick } from 'vue';
  164. import editModel from '@/views/dmx/model/components/editModel.vue';
  165. import addPageModel from './components/addPageModel.vue';
  166. import addTableName from './components/addTableName.vue';
  167. import {
  168. modelList,
  169. modelmyLlms,
  170. deleteLlm,
  171. deleteLlmFactory,
  172. } from '@/api/model';
  173. import { Modal, Message } from '@arco-design/web-vue';
  174. let count = 5;
  175. const activeKey = ref(1);
  176. const data = ref([
  177. {
  178. key: 1,
  179. title: 'key',
  180. content: 'Content of Tab Panel 1',
  181. },
  182. {
  183. key: 2,
  184. title: 'Ollama',
  185. content: 'Content of Tab Panel 2',
  186. },
  187. {
  188. key: 3,
  189. title: 'Xinference',
  190. content: 'Content of Tab Panel 3',
  191. },
  192. ]);
  193. const tabData = ref({
  194. key: {
  195. tags: '添加key',
  196. id: 1,
  197. },
  198. });
  199. const isDeleteDialogVisible = ref(false); //删除提醒
  200. const apiUrl = ref('http://127.0.0.1:5173');
  201. // const httpUrl = import.meta.env.VITE_API_BASE_URL;
  202. // console.log(apiUrl.value, 777);
  203. const modalList = ref({});
  204. const tabKey = ref('key');
  205. const changeTabs = (val) => {
  206. tabKey.value = val;
  207. };
  208. const show = ref(false);
  209. const tabShow = ref(false);
  210. const title = ref('添加模式');
  211. const task_id = ref(1);
  212. const modelType = ref(1);
  213. const handleAdd = () => {
  214. tabShow.value = true;
  215. title.value = '添加模型';
  216. editList.value.llm_factory = tabKey.value;
  217. };
  218. const editList = ref({ llm_factory: '' });
  219. //增加模型子类
  220. const handleAddModel = () => {
  221. modelType.value = 2;
  222. editList.value = [{ llm_factory: '' }];
  223. editList.value.llm_factory = tabKey.value;
  224. show.value = true;
  225. title.value = '添加模式';
  226. };
  227. //编辑模型子类
  228. const handleEditModel = (val, type) => {
  229. console.log(val, 6766);
  230. if (type == 1) {
  231. tabShow.value = true;
  232. editList.value = val;
  233. title.value = '编辑模型';
  234. editList.value.llm_factory = tabKey.value;
  235. } else {
  236. modelType.value = 2;
  237. task_id.value = val.id;
  238. show.value = true;
  239. title.value = '编辑';
  240. editList.value = val;
  241. editList.value.llm_factory = tabKey.value;
  242. }
  243. };
  244. //删除模型
  245. const handleDeleteModel = (val) => {
  246. Modal.confirm({
  247. title: '警告',
  248. content: '确认删除吗',
  249. okText: '确定',
  250. cancelText: '取消',
  251. onOk: async () => {
  252. const factory = tabKey.value;
  253. const res = await deleteLlm({
  254. llm_factory: tabKey.value,
  255. llm_name: val.name,
  256. });
  257. if ((res as any).code == 0) {
  258. queryModel();
  259. tabKey.value = factory;
  260. } else {
  261. }
  262. },
  263. onCancel: () => {},
  264. });
  265. };
  266. //父级模型
  267. const handleDelete = async (key: any) => {
  268. console.log(tabData.value[key]);
  269. if (tabData.value[key].llm.length > 0) {
  270. Message.error('请先删除子模型');
  271. return;
  272. }
  273. if (key !== 'key') {
  274. const res = await deleteLlmFactory(key);
  275. if (res.code == 200) {
  276. Reflect.deleteProperty(tabData.value, key);
  277. queryModel();
  278. }
  279. }
  280. };
  281. const visible = ref(false);
  282. const formRef = ref(null);
  283. const form = reactive({
  284. size: 'medium',
  285. name: '',
  286. });
  287. const handleOk = () => {
  288. count += 1;
  289. formRef.value?.validate().then((res) => {
  290. if (res) {
  291. return;
  292. }
  293. data.value = data.value.concat({
  294. key: count,
  295. title: `${form.name}`,
  296. content: ``,
  297. });
  298. visible.value = false;
  299. activeKey.value = count;
  300. });
  301. nextTick(() => {
  302. visible.value = true;
  303. });
  304. return false;
  305. };
  306. // const handleCancel = () => {
  307. // formRef.value.resetFields();
  308. // visible.value = false;
  309. // };
  310. // const handleSubmit = ({ values, errors }) => {
  311. // this.$refs.formRef.validate().then((res, a, b) => {
  312. // debugger;
  313. // console.log('values', values);
  314. // });
  315. // };
  316. //获取模型列表
  317. const loading = ref(false);
  318. const queryModel = async () => {
  319. const res = await modelmyLlms();
  320. modalList.value = res.data;
  321. loading.value = true;
  322. tabData.value = Object.assign({}, tabData.value, res.data);
  323. };
  324. queryModel();
  325. const refreshParentMethod = () => {
  326. queryModel();
  327. // 这里执行需要的操作
  328. };
  329. </script>
  330. <script lang="ts">
  331. export default {
  332. name: 'Card',
  333. };
  334. </script>
  335. <style scoped lang="less">
  336. .container {
  337. padding: 0 20px 20px 20px;
  338. :deep(.arco-list-content) {
  339. overflow-x: hidden;
  340. }
  341. :deep(.arco-card-meta-title) {
  342. font-size: 14px;
  343. }
  344. }
  345. :deep(.arco-list-col) {
  346. display: flex;
  347. flex-direction: row;
  348. flex-wrap: wrap;
  349. justify-content: space-between;
  350. }
  351. :deep(.arco-list-item) {
  352. width: 33%;
  353. }
  354. :deep(.block-title) {
  355. margin: 0 0 12px 0;
  356. font-size: 14px;
  357. }
  358. :deep(.list-wrap) {
  359. // min-height: 140px;
  360. .list-row {
  361. align-items: stretch;
  362. .list-col {
  363. margin-bottom: 16px;
  364. }
  365. }
  366. :deep(.arco-space) {
  367. width: 100%;
  368. .arco-space-item {
  369. &:last-child {
  370. flex: 1;
  371. }
  372. }
  373. }
  374. }
  375. :deep(.arco-tabs-nav-tab) {
  376. flex: none;
  377. width: 60%;
  378. }
  379. .table_add_clore {
  380. :deep(.arco-tabs-nav-add-btn .arco-icon-hover::before) {
  381. top: 50%;
  382. left: 50%;
  383. width: 20px;
  384. height: 20px;
  385. transform: translate(-50%, -50%);
  386. border-radius: 0;
  387. background-color: #165dff;
  388. }
  389. :deep(.arco-tabs-nav-add-btn .arco-icon-hover .arco-icon) {
  390. color: #fff;
  391. }
  392. // :deep(.arco-tabs-nav) {
  393. // max-width: 60%;
  394. // }
  395. :deep(.arco-icon-hover::before) {
  396. top: 50%;
  397. left: 50%;
  398. width: 20px;
  399. height: 20px;
  400. transform: translate(-50%, -50%);
  401. // border-radius: 0;
  402. // background-color: #eee;
  403. }
  404. :deep(.arco-tabs-tab-close-btn .arco-icon) {
  405. color: #666;
  406. }
  407. }
  408. .box_right {
  409. position: absolute;
  410. top: 60px;
  411. right: 20px;
  412. display: flex;
  413. .search_input {
  414. margin-right: 10px;
  415. }
  416. }
  417. .arco-card-body-content {
  418. .arco-card-body-content-title {
  419. font-size: 16px;
  420. color: #333;
  421. margin-bottom: 10px;
  422. font-weight: 400;
  423. }
  424. }
  425. .card_content {
  426. .card_wrap_box_img {
  427. min-height: 200px;
  428. height: 200px;
  429. img {
  430. max-height: 190px;
  431. }
  432. }
  433. .card_wrap_box {
  434. // position: relative;
  435. .arco-btn-group {
  436. position: absolute;
  437. right: 10px;
  438. top: 87%;
  439. }
  440. }
  441. }
  442. .card-wrap {
  443. width: 320px;
  444. height: 350px;
  445. margin: 30px;
  446. transition: all 0.3s;
  447. border: 1px solid var(--color-neutral-3);
  448. border-radius: 4px;
  449. &:hover {
  450. transform: translateY(-4px);
  451. // box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.1);
  452. }
  453. }
  454. .card-wrap {
  455. width: 320px;
  456. height: 350px;
  457. margin: 30px;
  458. transition: all 0.3s;
  459. border: 1px solid var(--color-neutral-3);
  460. border-radius: 4px;
  461. position: relative;
  462. &:hover {
  463. transform: translateY(-4px);
  464. // box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.1);
  465. }
  466. }
  467. .card-wrap {
  468. width: 320px;
  469. height: 350px;
  470. margin: 30px;
  471. transition: all 0.3s;
  472. border: 1px solid var(--color-neutral-3);
  473. border-radius: 4px;
  474. position: relative;
  475. &:hover {
  476. transform: translateY(-4px);
  477. // box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.1);
  478. }
  479. :deep(.arco-card) {
  480. height: 100%;
  481. border-radius: 4px;
  482. .arco-card-body {
  483. height: 100%;
  484. .arco-space {
  485. width: 100%;
  486. height: 100%;
  487. .arco-space-item {
  488. height: 100%;
  489. &:last-child {
  490. flex: 1;
  491. }
  492. .arco-card-meta {
  493. height: 100%;
  494. display: flex;
  495. flex-flow: column;
  496. .arco-card-meta-content {
  497. flex: 1;
  498. .arco-card-meta-description {
  499. margin-top: 8px;
  500. color: rgb(var(--gray-6));
  501. line-height: 20px;
  502. font-size: 12px;
  503. }
  504. }
  505. .arco-card-meta-footer {
  506. margin-top: 0;
  507. }
  508. }
  509. }
  510. }
  511. }
  512. }
  513. :deep(.arco-card-meta-title) {
  514. display: flex;
  515. align-items: center;
  516. // To prevent the shaking
  517. line-height: 28px;
  518. }
  519. :deep(.arco-skeleton-line) {
  520. &:last-child {
  521. display: flex;
  522. justify-content: flex-end;
  523. margin-top: 20px;
  524. }
  525. }
  526. }
  527. </style>