Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag ai correctly for premium #14959

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
} from "@budibase/bbui"
import { onMount, createEventDispatcher } from "svelte"
import { flags } from "stores/builder"
import { featureFlags } from "stores/portal"
import { featureFlags, licensing } from "stores/portal"
import { API } from "api"
import MagicWand from "../../../../assets/MagicWand.svelte"

Expand All @@ -26,7 +26,9 @@
let aiCronPrompt = ""
let loadingAICronExpression = false

$: aiEnabled = $featureFlags.AI_CUSTOM_CONFIGS || $featureFlags.BUDIBASE_AI
$: aiEnabled =
($featureFlags.AI_CUSTOM_CONFIGS && $licensing.customAIConfigsEnabled) ||
($featureFlags.BUDIBASE_AI && $licensing.budibaseAIEnabled)
$: {
if (cronExpression) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Tags,
Tag,
} from "@budibase/bbui"
import { admin, licensing } from "stores/portal"
import { admin, licensing, featureFlags } from "stores/portal"
import { API } from "api"
import AIConfigModal from "./ConfigModal.svelte"
import AIConfigTile from "./AIConfigTile.svelte"
Expand All @@ -27,7 +27,8 @@
let editingUuid

$: isCloud = $admin.cloud
$: customAIConfigsEnabled = $licensing.customAIConfigsEnabled
$: customAIConfigsEnabled =
$featureFlags.AI_CUSTOM_CONFIGS && $licensing.customAIConfigsEnabled

async function fetchAIConfig() {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script>
import { redirect } from "@roxi/routify"
import { licensing } from "stores/portal"
import { licensing, featureFlags } from "stores/portal"

if ($licensing.customAIConfigsEnabled) {
if ($featureFlags.AI_CUSTOM_CONFIGS && $licensing.customAIConfigsEnabled) {
$redirect("./ai")
} else {
$redirect("./auth")
Expand Down
17 changes: 13 additions & 4 deletions packages/server/src/api/controllers/row/staticFormula.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import {
processAIColumns,
processFormulas,
} from "../../../utilities/rowProcessor"
import { context } from "@budibase/backend-core"
import { Table, Row, FormulaType, FieldType, ViewV2 } from "@budibase/types"
import { context, features } from "@budibase/backend-core"
import {
Table,
Row,
FeatureFlag,
FormulaType,
FieldType,
ViewV2,
} from "@budibase/types"
import * as linkRows from "../../../db/linkedRows"
import isEqual from "lodash/isEqual"
import { cloneDeep } from "lodash/fp"
Expand Down Expand Up @@ -145,8 +152,10 @@ export async function finaliseRow(
contextRows: [enrichedRow],
})
const aiEnabled =
(await pro.features.isBudibaseAIEnabled()) ||
(await pro.features.isAICustomConfigsEnabled())
((await features.flags.isEnabled(FeatureFlag.BUDIBASE_AI)) &&
(await pro.features.isBudibaseAIEnabled())) ||
((await features.flags.isEnabled(FeatureFlag.AI_CUSTOM_CONFIGS)) &&
(await pro.features.isAICustomConfigsEnabled()))
if (aiEnabled) {
row = await processAIColumns(table, row, {
contextRows: [enrichedRow],
Expand Down
18 changes: 11 additions & 7 deletions packages/server/src/automations/steps/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import {
AutomationIOType,
OpenAIStepInputs,
OpenAIStepOutputs,
FeatureFlag,
} from "@budibase/types"
import { env } from "@budibase/backend-core"
import { env, features } from "@budibase/backend-core"
import * as automationUtils from "../automationUtils"
import * as pro from "@budibase/pro"

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 = "gpt-4o",
GPT_4 = "gpt-4",
GPT_35_TURBO = "gpt-3.5-turbo",
}

export const definition: AutomationStepDefinition = {
Expand Down Expand Up @@ -99,8 +99,12 @@ export async function run({

try {
let response
const customConfigsEnabled = await pro.features.isAICustomConfigsEnabled()
const budibaseAIEnabled = await pro.features.isBudibaseAIEnabled()
const customConfigsEnabled =
(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) {
const llm = await pro.ai.LargeLanguageModel.forCurrentTenant(inputs.model)
Expand Down
Loading