mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-02-07 06:09:17 +00:00
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
import { notifyIf } from '@baserow/modules/core/utils/error'
|
|
|
|
import FieldService from '@baserow_premium/services/field'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
generating: false,
|
|
}
|
|
},
|
|
computed: {
|
|
workspace() {
|
|
return this.$store.getters['workspace/get'](this.workspaceId)
|
|
},
|
|
modelAvailable() {
|
|
const aIModels =
|
|
this.$store.getters['settings/get'].generative_ai[
|
|
this.field.ai_generative_ai_type
|
|
] || []
|
|
return (
|
|
this.$registry
|
|
.get('field', this.field.type)
|
|
.isEnabled(this.workspace) &&
|
|
aIModels.includes(this.field.ai_generative_ai_model)
|
|
)
|
|
},
|
|
isDeactivated() {
|
|
return this.$registry
|
|
.get('field', this.field.type)
|
|
.isDeactivated(this.workspaceId)
|
|
},
|
|
deactivatedClickComponent() {
|
|
return this.$registry
|
|
.get('field', this.field.type)
|
|
.getDeactivatedClickModal(this.workspaceId)
|
|
},
|
|
},
|
|
watch: {
|
|
value() {
|
|
this.generating = false
|
|
},
|
|
},
|
|
methods: {
|
|
async generate() {
|
|
this.generating = true
|
|
try {
|
|
await FieldService(this.$client).generateAIFieldValues(this.field.id, [
|
|
this.$parent.row.id,
|
|
])
|
|
} catch (error) {
|
|
notifyIf(error, 'field')
|
|
this.generating = false
|
|
}
|
|
},
|
|
},
|
|
}
|