Checkpoint: Ajout de la configuration des champs obligatoires pour le score LLM

Nouvelle fonctionnalité permettant de configurer quels champs sont obligatoires ou optionnels pour atteindre un score de reconnaissance de 100%.

Modifications:
- Nouvelle table llmFieldsConfig dans la base de données
- Routes tRPC pour gérer la configuration (getAll, updateField)
- Interface utilisateur dans la page Paramètres avec tableau et cases à cocher
- Modification du code d'extraction pour générer dynamiquement l'instruction de score
- Initialisation automatique des champs par défaut (supplierName, invoiceNumber, invoiceDate, totalAmount obligatoires)
- Tests unitaires pour valider la fonctionnalité

L'utilisateur peut maintenant personnaliser quels champs doivent être détectés pour qu'une facture atteigne 100% de score.
This commit is contained in:
Manus
2026-02-13 03:39:41 -05:00
parent 96f6367094
commit d32359fc10
14 changed files with 1903 additions and 30 deletions

View File

@@ -0,0 +1,11 @@
CREATE TABLE `llmFieldsConfig` (
`id` int AUTO_INCREMENT NOT NULL,
`userId` int NOT NULL,
`fieldName` varchar(100) NOT NULL,
`displayName` varchar(255) NOT NULL,
`isRequired` int NOT NULL DEFAULT 1,
`displayOrder` int NOT NULL DEFAULT 0,
`createdAt` timestamp NOT NULL DEFAULT (now()),
`updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT `llmFieldsConfig_id` PRIMARY KEY(`id`)
);

File diff suppressed because it is too large Load Diff

View File

@@ -78,6 +78,13 @@
"when": 1770831408967,
"tag": "0010_late_thor_girl",
"breakpoints": true
},
{
"idx": 11,
"version": "5",
"when": 1770971673626,
"tag": "0011_woozy_sabretooth",
"breakpoints": true
}
]
}

View File

@@ -283,3 +283,22 @@ export const automationRules = mysqlTable("automationRules", {
export type AutomationRule = typeof automationRules.$inferSelect;
export type InsertAutomationRule = typeof automationRules.$inferInsert;
/**
* LLM Fields Configuration table
* Stores configuration for each field used in invoice extraction
* Allows users to define which fields are required for quality score calculation
*/
export const llmFieldsConfig = mysqlTable("llmFieldsConfig", {
id: int("id").autoincrement().primaryKey(),
userId: int("userId").notNull(), // Each user has their own configuration
fieldName: varchar("fieldName", { length: 100 }).notNull(), // Field identifier (supplierName, invoiceNumber, etc.)
displayName: varchar("displayName", { length: 255 }).notNull(), // Human-readable field name
isRequired: int("isRequired").default(1).notNull(), // 1 = required for 100% score, 0 = optional
displayOrder: int("displayOrder").default(0).notNull(), // Order in UI
createdAt: timestamp("createdAt").defaultNow().notNull(),
updatedAt: timestamp("updatedAt").defaultNow().onUpdateNow().notNull(),
});
export type LlmFieldConfig = typeof llmFieldsConfig.$inferSelect;
export type InsertLlmFieldConfig = typeof llmFieldsConfig.$inferInsert;