Model.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <vxe-grid resizable :data="list" :columns="columns" />
  3. </template>
  4. <script>
  5. import WindowsMixin from '@/mixins/windows'
  6. import ListMixin from '@/mixins/list'
  7. import { sizestr } from '@/utils/utils'
  8. export default {
  9. name: 'LlmModelList',
  10. mixins: [WindowsMixin, ListMixin],
  11. props: {
  12. id: String,
  13. getParams: {
  14. type: Object,
  15. default: () => { },
  16. },
  17. resId: String,
  18. },
  19. data () {
  20. return {
  21. list: [],
  22. columns: [
  23. {
  24. field: 'name',
  25. title: this.$t('aice.model'),
  26. },
  27. {
  28. field: 'id',
  29. title: 'ID',
  30. },
  31. {
  32. field: 'tag',
  33. title: 'Tag',
  34. },
  35. {
  36. field: 'size',
  37. title: 'Size',
  38. formatter: ({ row }) => {
  39. return sizestr(row.size, 'B', 1024)
  40. },
  41. },
  42. {
  43. field: '_action',
  44. title: this.$t('table.title._action'),
  45. slots: {
  46. default: ({ row }) => {
  47. return [
  48. <a-button type="link" size="small" onClick={ () => {
  49. this.createDialog('LlmModelSaveInstantModelDialog', {
  50. data: [row],
  51. resId: this.resId,
  52. actionText: this.$t('aice.save_as_instant_model'),
  53. success: () => {
  54. //
  55. },
  56. })
  57. } }>{this.$t('aice.save_as_instant_model')}</a-button>,
  58. ]
  59. },
  60. },
  61. },
  62. ],
  63. }
  64. },
  65. computed: {
  66. exportDataOptions () {
  67. return {
  68. downloadType: 'local',
  69. title: this.$t('aice.image'),
  70. items: [
  71. { label: 'ID', key: 'id' },
  72. ...this.columns,
  73. ],
  74. }
  75. },
  76. },
  77. created () {
  78. this.fetchData()
  79. },
  80. methods: {
  81. async fetchData () {
  82. const response = await new this.$Manager(`llms/${this.resId}/probed-models`, 'v2').list({
  83. params: {
  84. scope: this.$store.getters.scope,
  85. },
  86. })
  87. const { data } = response
  88. const keys = Object.keys(data)
  89. this.list = keys.map(key => {
  90. return {
  91. id: data[key].model_id,
  92. ...data[key],
  93. }
  94. })
  95. },
  96. },
  97. }
  98. </script>
  99. <style>
  100. </style>