lint
This commit is contained in:
parent
9a4a788283
commit
2dff149aa9
|
@ -106,7 +106,8 @@
|
||||||
let optionsValid = true
|
let optionsValid = true
|
||||||
|
|
||||||
$: rowGoldenSample = RowUtils.generateGoldenSample($rows)
|
$: rowGoldenSample = RowUtils.generateGoldenSample($rows)
|
||||||
$: aiEnabled = $licensing.customAIConfigsEnabled || $licensing.budibaseAIEnabled
|
$: aiEnabled =
|
||||||
|
$licensing.customAIConfigsEnabled || $licensing.budibaseAIEnabled
|
||||||
$: if (primaryDisplay) {
|
$: if (primaryDisplay) {
|
||||||
editableColumn.constraints.presence = { allowEmpty: false }
|
editableColumn.constraints.presence = { allowEmpty: false }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +1,12 @@
|
||||||
<script>
|
<script>
|
||||||
import { Input, Helpers, Multiselect, Select, TextArea } from "@budibase/bbui"
|
import { Helpers, Multiselect, Select } from "@budibase/bbui"
|
||||||
import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte"
|
import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte"
|
||||||
import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte"
|
import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte"
|
||||||
|
import {
|
||||||
const AIOperations = {
|
AIOperations,
|
||||||
SUMMARISE_TEXT: {
|
OperationFields,
|
||||||
label: "Summarise Text",
|
OperationFieldTypes,
|
||||||
value: "SUMMARISE_TEXT",
|
} from "@budibase/shared-core"
|
||||||
},
|
|
||||||
CLEAN_DATA: {
|
|
||||||
label: "Clean Data",
|
|
||||||
value: "CLEAN_DATA",
|
|
||||||
},
|
|
||||||
TRANSLATE: {
|
|
||||||
label: "Translate",
|
|
||||||
value: "TRANSLATE",
|
|
||||||
},
|
|
||||||
CATEGORISE_TEXT: {
|
|
||||||
label: "Categorise Text",
|
|
||||||
value: "CATEGORISE_TEXT",
|
|
||||||
},
|
|
||||||
SENTIMENT_ANALYSIS: {
|
|
||||||
label: "Sentiment Analysis",
|
|
||||||
value: "SENTIMENT_ANALYSIS",
|
|
||||||
},
|
|
||||||
PROMPT: {
|
|
||||||
label: "Prompt",
|
|
||||||
value: "PROMPT",
|
|
||||||
},
|
|
||||||
SEARCH_WEB: {
|
|
||||||
label: "Search Web",
|
|
||||||
value: "SEARCH_WEB",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const OperationFieldTypes = {
|
|
||||||
MULTI_COLUMN: "columns",
|
|
||||||
COLUMN: "column",
|
|
||||||
BINDABLE_TEXT: "prompt",
|
|
||||||
// LANGUAGE: "language",
|
|
||||||
}
|
|
||||||
|
|
||||||
const OperationFields = {
|
|
||||||
SUMMARISE_TEXT: {
|
|
||||||
columns: OperationFieldTypes.MULTI_COLUMN,
|
|
||||||
},
|
|
||||||
CLEAN_DATA: {
|
|
||||||
column: OperationFieldTypes.COLUMN,
|
|
||||||
},
|
|
||||||
TRANSLATE: {
|
|
||||||
column: OperationFieldTypes.COLUMN,
|
|
||||||
language: OperationFieldTypes.BINDABLE_TEXT,
|
|
||||||
},
|
|
||||||
CATEGORISE_TEXT: {
|
|
||||||
columns: OperationFieldTypes.MULTI_COLUMN,
|
|
||||||
categories: OperationFieldTypes.BINDABLE_TEXT,
|
|
||||||
},
|
|
||||||
SENTIMENT_ANALYSIS: {
|
|
||||||
column: OperationFieldTypes.COLUMN,
|
|
||||||
},
|
|
||||||
PROMPT: {
|
|
||||||
prompt: OperationFieldTypes.BINDABLE_TEXT,
|
|
||||||
},
|
|
||||||
SEARCH_WEB: {
|
|
||||||
columns: OperationFieldTypes.MULTI_COLUMN,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const AIFieldConfigOptions = Object.keys(AIOperations).map(key => ({
|
const AIFieldConfigOptions = Object.keys(AIOperations).map(key => ({
|
||||||
label: AIOperations[key].label,
|
label: AIOperations[key].label,
|
||||||
|
@ -78,8 +19,6 @@
|
||||||
export let aiField = {}
|
export let aiField = {}
|
||||||
|
|
||||||
$: OperationField = OperationFields[aiField.operation] || null
|
$: OperationField = OperationFields[aiField.operation] || null
|
||||||
$: console.log(aiField)
|
|
||||||
$: console.log(schema)
|
|
||||||
$: schemaWithoutRelations = Object.keys(schema).filter(
|
$: schemaWithoutRelations = Object.keys(schema).filter(
|
||||||
key => schema[key].type !== "link"
|
key => schema[key].type !== "link"
|
||||||
)
|
)
|
||||||
|
|
|
@ -42,11 +42,7 @@
|
||||||
|
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<div
|
<div class="long-form-cell" on:click={open} bind:this={anchor}>
|
||||||
class="long-form-cell"
|
|
||||||
on:click={open}
|
|
||||||
bind:this={anchor}
|
|
||||||
>
|
|
||||||
<div class="value">
|
<div class="value">
|
||||||
{value || ""}
|
{value || ""}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,9 +15,7 @@ import {
|
||||||
import { EventType, updateLinks } from "../../../../db/linkedRows"
|
import { EventType, updateLinks } from "../../../../db/linkedRows"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import isEqual from "lodash/isEqual"
|
import isEqual from "lodash/isEqual"
|
||||||
import {
|
import { runStaticFormulaChecks } from "../../../../api/controllers/table/bulkFormula"
|
||||||
runStaticFormulaChecks,
|
|
||||||
} from "../../../../api/controllers/table/bulkFormula"
|
|
||||||
import { context } from "@budibase/backend-core"
|
import { context } from "@budibase/backend-core"
|
||||||
import { findDuplicateInternalColumns } from "@budibase/shared-core"
|
import { findDuplicateInternalColumns } from "@budibase/shared-core"
|
||||||
import { getTable } from "../getters"
|
import { getTable } from "../getters"
|
||||||
|
|
|
@ -8,7 +8,10 @@ import {
|
||||||
FormulaType,
|
FormulaType,
|
||||||
AutoFieldSubType,
|
AutoFieldSubType,
|
||||||
FieldType,
|
FieldType,
|
||||||
|
OperationFieldTypeEnum,
|
||||||
|
AIFieldMetadata,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
import { OperationFields } from "@budibase/shared-core"
|
||||||
import tracer from "dd-trace"
|
import tracer from "dd-trace"
|
||||||
import { context } from "@budibase/backend-core"
|
import { context } from "@budibase/backend-core"
|
||||||
import * as pro from "@budibase/pro"
|
import * as pro from "@budibase/pro"
|
||||||
|
@ -116,12 +119,13 @@ export async function processAIColumns<T extends Row | Row[]>(
|
||||||
|
|
||||||
const rowUpdates = rows.map((row, i) => {
|
const rowUpdates = rows.map((row, i) => {
|
||||||
const contextRow = contextRows ? contextRows[i] : row
|
const contextRow = contextRows ? contextRows[i] : row
|
||||||
// TODO: Map the prompts with string-templates
|
|
||||||
// grab the operation based on the schema
|
// Check if the type is bindable and pass through HBS if so
|
||||||
// then check the types in the fields, and decide whether to pass them through string templates
|
const operationField =
|
||||||
// TODO: cleaner way to map to the schema, move things into BB types and check against the AI schema
|
OperationFields[(schema as AIFieldMetadata).operation]
|
||||||
for (const key in schema) {
|
for (const key in schema) {
|
||||||
if (["prompt", "categories"].includes(key)) {
|
const fieldType = operationField[key]
|
||||||
|
if (fieldType === OperationFieldTypeEnum.BINDABLE_TEXT) {
|
||||||
schema[key] = processStringSync(schema[key], contextRow)
|
schema[key] = processStringSync(schema[key], contextRow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
import {
|
||||||
|
AIOperationEnum,
|
||||||
|
OperationFieldsType,
|
||||||
|
OperationFieldTypeEnum,
|
||||||
|
} from "@budibase/types"
|
||||||
|
|
||||||
|
const AIOperations = {
|
||||||
|
SUMMARISE_TEXT: {
|
||||||
|
label: "Summarise Text",
|
||||||
|
value: "SUMMARISE_TEXT",
|
||||||
|
},
|
||||||
|
CLEAN_DATA: {
|
||||||
|
label: "Clean Data",
|
||||||
|
value: "CLEAN_DATA",
|
||||||
|
},
|
||||||
|
TRANSLATE: {
|
||||||
|
label: "Translate",
|
||||||
|
value: "TRANSLATE",
|
||||||
|
},
|
||||||
|
CATEGORISE_TEXT: {
|
||||||
|
label: "Categorise Text",
|
||||||
|
value: "CATEGORISE_TEXT",
|
||||||
|
},
|
||||||
|
SENTIMENT_ANALYSIS: {
|
||||||
|
label: "Sentiment Analysis",
|
||||||
|
value: "SENTIMENT_ANALYSIS",
|
||||||
|
},
|
||||||
|
PROMPT: {
|
||||||
|
label: "Prompt",
|
||||||
|
value: "PROMPT",
|
||||||
|
},
|
||||||
|
SEARCH_WEB: {
|
||||||
|
label: "Search Web",
|
||||||
|
value: "SEARCH_WEB",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export const OperationFieldTypes = {
|
||||||
|
MULTI_COLUMN: "columns",
|
||||||
|
COLUMN: "column",
|
||||||
|
BINDABLE_TEXT: "prompt",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const OperationFields: OperationFieldsType = {
|
||||||
|
[AIOperationEnum.SUMMARISE_TEXT]: {
|
||||||
|
columns: OperationFieldTypeEnum.MULTI_COLUMN,
|
||||||
|
},
|
||||||
|
[AIOperationEnum.CLEAN_DATA]: {
|
||||||
|
column: OperationFieldTypeEnum.COLUMN,
|
||||||
|
},
|
||||||
|
[AIOperationEnum.TRANSLATE]: {
|
||||||
|
column: OperationFieldTypeEnum.COLUMN,
|
||||||
|
language: OperationFieldTypeEnum.BINDABLE_TEXT,
|
||||||
|
},
|
||||||
|
[AIOperationEnum.CATEGORISE_TEXT]: {
|
||||||
|
columns: OperationFieldTypeEnum.MULTI_COLUMN,
|
||||||
|
categories: OperationFieldTypeEnum.BINDABLE_TEXT,
|
||||||
|
},
|
||||||
|
[AIOperationEnum.SENTIMENT_ANALYSIS]: {
|
||||||
|
column: OperationFieldTypeEnum.COLUMN,
|
||||||
|
},
|
||||||
|
[AIOperationEnum.PROMPT]: {
|
||||||
|
prompt: OperationFieldTypeEnum.BINDABLE_TEXT,
|
||||||
|
},
|
||||||
|
[AIOperationEnum.SEARCH_WEB]: {
|
||||||
|
columns: OperationFieldTypeEnum.MULTI_COLUMN,
|
||||||
|
},
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
export * from "./ai"
|
||||||
export * from "./api"
|
export * from "./api"
|
||||||
export * from "./fields"
|
export * from "./fields"
|
||||||
export * from "./rows"
|
export * from "./rows"
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
export * from "./ai"
|
|
||||||
export * from "./app"
|
export * from "./app"
|
||||||
export * from "./automation"
|
export * from "./automation"
|
||||||
export * from "./datasource"
|
export * from "./datasource"
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
JsonFieldSubType,
|
JsonFieldSubType,
|
||||||
RelationshipType,
|
RelationshipType,
|
||||||
} from "./constants"
|
} from "./constants"
|
||||||
import { AIOperationEnum } from "../ai"
|
import { AIOperationEnum } from "../../../sdk/ai"
|
||||||
|
|
||||||
export interface UIFieldMetadata {
|
export interface UIFieldMetadata {
|
||||||
order?: number
|
order?: number
|
||||||
|
|
|
@ -8,13 +8,13 @@ export enum AIOperationEnum {
|
||||||
SEARCH_WEB = "SEARCH_WEB",
|
SEARCH_WEB = "SEARCH_WEB",
|
||||||
}
|
}
|
||||||
|
|
||||||
enum OperationFieldTypeEnum {
|
export enum OperationFieldTypeEnum {
|
||||||
MULTI_COLUMN = "columns",
|
MULTI_COLUMN = "columns",
|
||||||
COLUMN = "column",
|
COLUMN = "column",
|
||||||
BINDABLE_TEXT = "prompt",
|
BINDABLE_TEXT = "prompt",
|
||||||
}
|
}
|
||||||
|
|
||||||
type OperationFieldsType = {
|
export type OperationFieldsType = {
|
||||||
[AIOperationEnum.SUMMARISE_TEXT]: {
|
[AIOperationEnum.SUMMARISE_TEXT]: {
|
||||||
columns: OperationFieldTypeEnum.MULTI_COLUMN
|
columns: OperationFieldTypeEnum.MULTI_COLUMN
|
||||||
}
|
}
|
||||||
|
@ -40,17 +40,6 @@ type OperationFieldsType = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the AI operations with just their labels (no need for separate 'value' property)
|
|
||||||
const AIOperations: { [key in AIOperationEnum]: string } = {
|
|
||||||
[AIOperationEnum.SUMMARISE_TEXT]: "Summarise Text",
|
|
||||||
[AIOperationEnum.CLEAN_DATA]: "Clean Data",
|
|
||||||
[AIOperationEnum.TRANSLATE]: "Translate",
|
|
||||||
[AIOperationEnum.CATEGORISE_TEXT]: "Categorise Text",
|
|
||||||
[AIOperationEnum.SENTIMENT_ANALYSIS]: "Sentiment Analysis",
|
|
||||||
[AIOperationEnum.PROMPT]: "Prompt",
|
|
||||||
[AIOperationEnum.SEARCH_WEB]: "Search Web",
|
|
||||||
}
|
|
||||||
|
|
||||||
type BaseSchema = {
|
type BaseSchema = {
|
||||||
operation: AIOperationEnum
|
operation: AIOperationEnum
|
||||||
}
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
export * from "./ai"
|
||||||
export * from "./automations"
|
export * from "./automations"
|
||||||
export * from "./hosting"
|
export * from "./hosting"
|
||||||
export * from "./context"
|
export * from "./context"
|
||||||
|
|
Loading…
Reference in New Issue