QuickModel.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{action}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="isApplyType ? $t('aice.app_llm') : $t('aice.llm')" :count="params.data.length" :action="action" />
  6. <dialog-table :data="params.data" :columns="columns" />
  7. <a-form :form="form.fc" v-bind="formItemLayout">
  8. <a-form-item :label="$t('aice.model')">
  9. <base-select v-decorator="decorators.model" :options="modelOptions" :select-props="{ placeholder: $t('common.tips.select', [$t('aice.model')]) }" />
  10. </a-form-item>
  11. </a-form>
  12. </div>
  13. <div slot="footer">
  14. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  15. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  16. </div>
  17. </base-dialog>
  18. </template>
  19. <script>
  20. import { mapGetters } from 'vuex'
  21. import DialogMixin from '@/mixins/dialog'
  22. import WindowsMixin from '@/mixins/windows'
  23. export default {
  24. name: 'LlmQuickModelDialog',
  25. mixins: [DialogMixin, WindowsMixin],
  26. data () {
  27. return {
  28. isApplyType: this.$route.path.includes('app-llm'),
  29. loading: false,
  30. action: this.params.actionText,
  31. form: {
  32. fc: this.$form.createForm(this, {
  33. onValuesChange: (props, values) => {
  34. Object.keys(values).forEach((key) => {
  35. this.form.fd[key] = values[key]
  36. })
  37. },
  38. }),
  39. fd: {
  40. model: [],
  41. },
  42. },
  43. decorators: {
  44. model: [
  45. 'model',
  46. {
  47. initialValue: [],
  48. rules: [
  49. { required: true, message: this.$t('common.tips.select', [this.$t('aice.model')]) },
  50. ],
  51. },
  52. ],
  53. },
  54. formItemLayout: {
  55. wrapperCol: {
  56. span: 20,
  57. },
  58. labelCol: {
  59. span: 4,
  60. },
  61. },
  62. modelOptions: [],
  63. }
  64. },
  65. computed: {
  66. ...mapGetters(['userInfo']),
  67. columns () {
  68. const showFields = ['name', 'phone_ip', 'phone_image', 'phone_model']
  69. return this.params.columns.filter((item) => { return showFields.includes(item.field) })
  70. },
  71. },
  72. created () {
  73. this.$hM = new this.$Manager('llms')
  74. this.queryModels()
  75. },
  76. methods: {
  77. async queryModels () {
  78. const response = await new this.$Manager(`llms/${this.params.data[0].id}/probed-models`, 'v2').list({
  79. params: {
  80. scope: this.$store.getters.scope,
  81. },
  82. })
  83. const { data } = response
  84. const keys = Object.keys(data)
  85. this.modelOptions = keys.map(key => {
  86. return {
  87. id: data[key].model_id,
  88. ...data[key],
  89. }
  90. })
  91. },
  92. async doSubmit () {
  93. const data = { method: 'install' }
  94. data.model = this.form.fd.model
  95. const ids = this.params.data.map(item => item.id)
  96. return this.params.onManager('batchPerformAction', {
  97. id: ids,
  98. // steadyStatus: 'ready',
  99. managerArgs: {
  100. action: 'quick-models',
  101. data,
  102. },
  103. })
  104. },
  105. async handleConfirm () {
  106. this.loading = true
  107. try {
  108. await this.doSubmit()
  109. this.loading = false
  110. this.cancelDialog()
  111. } catch (error) {
  112. this.loading = false
  113. throw error
  114. }
  115. },
  116. },
  117. }
  118. </script>