flag ai with feature flags correctly
This commit is contained in:
parent
52b48db5eb
commit
7b867abd19
|
@ -4,8 +4,15 @@ import {
|
||||||
processAIColumns,
|
processAIColumns,
|
||||||
processFormulas,
|
processFormulas,
|
||||||
} from "../../../utilities/rowProcessor"
|
} from "../../../utilities/rowProcessor"
|
||||||
import { context } from "@budibase/backend-core"
|
import { context, features } from "@budibase/backend-core"
|
||||||
import { Table, Row, FormulaType, FieldType, ViewV2 } from "@budibase/types"
|
import {
|
||||||
|
Table,
|
||||||
|
Row,
|
||||||
|
FeatureFlag,
|
||||||
|
FormulaType,
|
||||||
|
FieldType,
|
||||||
|
ViewV2,
|
||||||
|
} from "@budibase/types"
|
||||||
import * as linkRows from "../../../db/linkedRows"
|
import * as linkRows from "../../../db/linkedRows"
|
||||||
import isEqual from "lodash/isEqual"
|
import isEqual from "lodash/isEqual"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
@ -145,8 +152,10 @@ export async function finaliseRow(
|
||||||
contextRows: [enrichedRow],
|
contextRows: [enrichedRow],
|
||||||
})
|
})
|
||||||
const aiEnabled =
|
const aiEnabled =
|
||||||
(await pro.features.isBudibaseAIEnabled()) ||
|
((await features.flags.isEnabled(FeatureFlag.BUDIBASE_AI)) &&
|
||||||
(await pro.features.isAICustomConfigsEnabled())
|
(await pro.features.isBudibaseAIEnabled())) ||
|
||||||
|
((await features.flags.isEnabled(FeatureFlag.AI_CUSTOM_CONFIGS)) &&
|
||||||
|
(await pro.features.isAICustomConfigsEnabled()))
|
||||||
if (aiEnabled) {
|
if (aiEnabled) {
|
||||||
row = await processAIColumns(table, row, {
|
row = await processAIColumns(table, row, {
|
||||||
contextRows: [enrichedRow],
|
contextRows: [enrichedRow],
|
||||||
|
|
|
@ -7,17 +7,17 @@ import {
|
||||||
AutomationIOType,
|
AutomationIOType,
|
||||||
OpenAIStepInputs,
|
OpenAIStepInputs,
|
||||||
OpenAIStepOutputs,
|
OpenAIStepOutputs,
|
||||||
|
FeatureFlag,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { env } from "@budibase/backend-core"
|
import { env, features } from "@budibase/backend-core"
|
||||||
import * as automationUtils from "../automationUtils"
|
import * as automationUtils from "../automationUtils"
|
||||||
import * as pro from "@budibase/pro"
|
import * as pro from "@budibase/pro"
|
||||||
|
|
||||||
enum Model {
|
enum Model {
|
||||||
GPT_35_TURBO = "gpt-3.5-turbo",
|
|
||||||
// will only work with api keys that have access to the GPT4 API
|
|
||||||
GPT_4 = "gpt-4",
|
|
||||||
GPT_4O = "gpt-4o",
|
|
||||||
GPT_4O_MINI = "gpt-4o-mini",
|
GPT_4O_MINI = "gpt-4o-mini",
|
||||||
|
GPT_4O = "gpt-4o",
|
||||||
|
GPT_4 = "gpt-4",
|
||||||
|
GPT_35_TURBO = "gpt-3.5-turbo",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const definition: AutomationStepDefinition = {
|
export const definition: AutomationStepDefinition = {
|
||||||
|
@ -99,8 +99,12 @@ export async function run({
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let response
|
let response
|
||||||
const customConfigsEnabled = await pro.features.isAICustomConfigsEnabled()
|
const customConfigsEnabled =
|
||||||
const budibaseAIEnabled = await pro.features.isBudibaseAIEnabled()
|
(await features.flags.isEnabled(FeatureFlag.AI_CUSTOM_CONFIGS)) &&
|
||||||
|
(await pro.features.isAICustomConfigsEnabled())
|
||||||
|
const budibaseAIEnabled =
|
||||||
|
(await features.flags.isEnabled(FeatureFlag.BUDIBASE_AI)) &&
|
||||||
|
(await pro.features.isBudibaseAIEnabled())
|
||||||
|
|
||||||
if (budibaseAIEnabled || customConfigsEnabled) {
|
if (budibaseAIEnabled || customConfigsEnabled) {
|
||||||
const llm = await pro.ai.LargeLanguageModel.forCurrentTenant(inputs.model)
|
const llm = await pro.ai.LargeLanguageModel.forCurrentTenant(inputs.model)
|
||||||
|
|
Loading…
Reference in New Issue