fix error TS2322: Type '{ category: string; threshold: string; }[]' is not assignable to type 'SafetySetting[]

This commit is contained in:
chungyau97 2024-01-14 00:51:28 +08:00
parent c15250f28b
commit bdc892df2b
1 changed files with 2 additions and 2 deletions

View File

@ -177,13 +177,13 @@ class GoogleGenerativeAI_ChatModels implements INode {
let harmBlockThresholds: string[] = convertStringToArrayString(harmBlockThreshold)
if (harmCategories.length != harmBlockThresholds.length)
throw new Error(`Harm Category & Harm Block Threshold are not the same length`)
const safetySettings = harmCategories.map((value, index) => {
const safetySettings: typeof model.safetySettings = harmCategories.map((value, index) => {
return {
category: value,
threshold: harmBlockThresholds[index]
}
})
if (safetySettings) model.safetySettings = safetySettings
if (safetySettings.length > 0) model.safetySettings = safetySettings
return model
}