lint and types
This commit is contained in:
parent
97a7649930
commit
95d8ad854c
|
@ -343,12 +343,6 @@ describe("/datasources", () => {
|
||||||
type: FieldType.FORMULA,
|
type: FieldType.FORMULA,
|
||||||
formula: "any formula",
|
formula: "any formula",
|
||||||
},
|
},
|
||||||
[FieldType.AI]: {
|
|
||||||
name: "ai",
|
|
||||||
type: FieldType.AI,
|
|
||||||
operation: "PROMPT",
|
|
||||||
prompt: "test prompt",
|
|
||||||
},
|
|
||||||
[FieldType.BARCODEQR]: {
|
[FieldType.BARCODEQR]: {
|
||||||
name: "barcodeqr",
|
name: "barcodeqr",
|
||||||
type: FieldType.BARCODEQR,
|
type: FieldType.BARCODEQR,
|
||||||
|
|
|
@ -206,7 +206,7 @@ describe.each([
|
||||||
visible: false,
|
visible: false,
|
||||||
icon: "ic",
|
icon: "ic",
|
||||||
},
|
},
|
||||||
} as Record<string, FieldSchema>,
|
} as ViewV2Schema,
|
||||||
}
|
}
|
||||||
|
|
||||||
const createdView = await config.api.viewV2.create(newView)
|
const createdView = await config.api.viewV2.create(newView)
|
||||||
|
@ -250,7 +250,7 @@ describe.each([
|
||||||
name: "Category",
|
name: "Category",
|
||||||
type: FieldType.STRING,
|
type: FieldType.STRING,
|
||||||
},
|
},
|
||||||
} as Record<string, FieldSchema>,
|
} as ViewV2Schema,
|
||||||
}
|
}
|
||||||
|
|
||||||
await config.api.viewV2.create(newView, {
|
await config.api.viewV2.create(newView, {
|
||||||
|
@ -1044,7 +1044,7 @@ describe.each([
|
||||||
visible: false,
|
visible: false,
|
||||||
icon: "ic",
|
icon: "ic",
|
||||||
},
|
},
|
||||||
} as Record<string, FieldSchema>,
|
} as ViewV2Schema,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(updatedView).toEqual({
|
expect(updatedView).toEqual({
|
||||||
|
@ -1078,7 +1078,7 @@ describe.each([
|
||||||
name: "Category",
|
name: "Category",
|
||||||
type: FieldType.STRING,
|
type: FieldType.STRING,
|
||||||
},
|
},
|
||||||
} as Record<string, FieldSchema>,
|
} as ViewV2Schema,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
AutoFieldSubType,
|
AutoFieldSubType,
|
||||||
FieldType,
|
FieldType,
|
||||||
OperationFieldTypeEnum,
|
OperationFieldTypeEnum,
|
||||||
AIFieldMetadata,
|
AIOperationEnum,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { OperationFields } from "@budibase/shared-core"
|
import { OperationFields } from "@budibase/shared-core"
|
||||||
import tracer from "dd-trace"
|
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
|
// Check if the type is bindable and pass through HBS if so
|
||||||
const operationField =
|
const operationField =
|
||||||
OperationFields[(schema as AIFieldMetadata).operation]
|
OperationFields[schema.operation as AIOperationEnum]
|
||||||
for (const key in schema) {
|
for (const key in schema) {
|
||||||
const fieldType = operationField[key]
|
const fieldType = operationField[key as keyof typeof operationField]
|
||||||
if (fieldType === OperationFieldTypeEnum.BINDABLE_TEXT) {
|
if (fieldType === OperationFieldTypeEnum.BINDABLE_TEXT) {
|
||||||
|
// @ts-ignore
|
||||||
schema[key] = processStringSync(schema[key], contextRow)
|
schema[key] = processStringSync(schema[key], contextRow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +135,7 @@ export async function processAIColumns<T extends Row | Row[]>(
|
||||||
|
|
||||||
return tracer.trace("processAIColumn", {}, async span => {
|
return tracer.trace("processAIColumn", {}, async span => {
|
||||||
span?.addTags({ table_id: table._id, column })
|
span?.addTags({ table_id: table._id, column })
|
||||||
const llmResponse = await llm.run(prompt)
|
const llmResponse = await llm.run(prompt!)
|
||||||
return {
|
return {
|
||||||
...row,
|
...row,
|
||||||
[column]: llmResponse,
|
[column]: llmResponse,
|
||||||
|
|
|
@ -122,7 +122,7 @@ export interface AIFieldMetadata extends BaseFieldSchema {
|
||||||
operation: AIOperationEnum
|
operation: AIOperationEnum
|
||||||
columns?: string[]
|
columns?: string[]
|
||||||
column?: string
|
column?: string
|
||||||
categories?: string
|
categories?: string[]
|
||||||
prompt?: string
|
prompt?: string
|
||||||
language?: string
|
language?: string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue