lint and types

This commit is contained in:
Martin McKeaveney 2024-10-14 23:36:33 +01:00
parent 97a7649930
commit 95d8ad854c
4 changed files with 10 additions and 15 deletions

View File

@ -343,12 +343,6 @@ describe("/datasources", () => {
type: FieldType.FORMULA,
formula: "any formula",
},
[FieldType.AI]: {
name: "ai",
type: FieldType.AI,
operation: "PROMPT",
prompt: "test prompt",
},
[FieldType.BARCODEQR]: {
name: "barcodeqr",
type: FieldType.BARCODEQR,

View File

@ -206,7 +206,7 @@ describe.each([
visible: false,
icon: "ic",
},
} as Record<string, FieldSchema>,
} as ViewV2Schema,
}
const createdView = await config.api.viewV2.create(newView)
@ -250,7 +250,7 @@ describe.each([
name: "Category",
type: FieldType.STRING,
},
} as Record<string, FieldSchema>,
} as ViewV2Schema,
}
await config.api.viewV2.create(newView, {
@ -1044,7 +1044,7 @@ describe.each([
visible: false,
icon: "ic",
},
} as Record<string, FieldSchema>,
} as ViewV2Schema,
})
expect(updatedView).toEqual({
@ -1078,7 +1078,7 @@ describe.each([
name: "Category",
type: FieldType.STRING,
},
} as Record<string, FieldSchema>,
} as ViewV2Schema,
},
{
status: 200,

View File

@ -9,7 +9,7 @@ import {
AutoFieldSubType,
FieldType,
OperationFieldTypeEnum,
AIFieldMetadata,
AIOperationEnum,
} from "@budibase/types"
import { OperationFields } from "@budibase/shared-core"
import tracer from "dd-trace"
@ -122,10 +122,11 @@ export async function processAIColumns<T extends Row | Row[]>(
// Check if the type is bindable and pass through HBS if so
const operationField =
OperationFields[(schema as AIFieldMetadata).operation]
OperationFields[schema.operation as AIOperationEnum]
for (const key in schema) {
const fieldType = operationField[key]
const fieldType = operationField[key as keyof typeof operationField]
if (fieldType === OperationFieldTypeEnum.BINDABLE_TEXT) {
// @ts-ignore
schema[key] = processStringSync(schema[key], contextRow)
}
}
@ -134,7 +135,7 @@ export async function processAIColumns<T extends Row | Row[]>(
return tracer.trace("processAIColumn", {}, async span => {
span?.addTags({ table_id: table._id, column })
const llmResponse = await llm.run(prompt)
const llmResponse = await llm.run(prompt!)
return {
...row,
[column]: llmResponse,

View File

@ -122,7 +122,7 @@ export interface AIFieldMetadata extends BaseFieldSchema {
operation: AIOperationEnum
columns?: string[]
column?: string
categories?: string
categories?: string[]
prompt?: string
language?: string
}