Teach local AI from user category corrections
- Add MerchantCorrection model: upsert by merchantName, Category enum - Check corrections DB first in suggestCategoryForMerchant (source: "learned", no confirmation required); falls through to rules then Ollama if no match - Inject recent corrections as few-shot examples in the Ollama prompt so the model improves even for merchants not yet explicitly corrected - Add POST /categories/correct route to persist corrections - Detect category override on form save (suggestedCategory !== chosen category) and silently fire a correction — no extra UX required - Fix test isolation: beforeEach re-applies vi.fn() defaults after restoreAllMocks Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "MerchantCorrection" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"merchantName" TEXT NOT NULL,
|
||||
"category" TEXT NOT NULL,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "MerchantCorrection_merchantName_key" ON "MerchantCorrection"("merchantName");
|
||||
Reference in New Issue
Block a user