feat(categories): add new categories for Kondis & fika and Kaffebröd, and Te & choklad

This commit is contained in:
Nils-Johan Gynther
2026-05-02 17:44:01 +02:00
parent 1604751b65
commit ec24f49836
5 changed files with 139 additions and 3 deletions
+18
View File
@@ -120,6 +120,24 @@ Regler:
? (parsed.confidence as 'high' | 'medium' | 'low')
: 'medium';
// Guardrail: för låg/medel konfidenspoäng, remmappa till L1-föräldern
if (confidence === 'low' || confidence === 'medium') {
const l1Name = matchedCategory.path.split(' > ')[0];
const l1 = categories.find((c) => c.path === l1Name);
if (l1 && l1.id !== matchedCategory.id) {
this.logger.log(
`AI-guardrail: ${confidence} konfidenspoäng → remappar "${matchedCategory.path}" → L1 "${l1.path}"`,
);
return {
categoryId: l1.id,
categoryName: l1.name,
path: l1.path,
confidence,
usedFallback: true,
};
}
}
return {
categoryId: matchedCategory.id,
categoryName: matchedCategory.name,