fix(ai): cap extract-invoices batch at 20 files

Final review flagged that the multipart limits set only fileSize, so a
single /extract-invoices request could carry unbounded PDF parts. The
per-batch budget re-check already bounds total spend, but this bounds the
work (one vision call per file) of any single request.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-08 15:05:16 +02:00
parent b665ea1d9b
commit 0226cdd52b

View File

@@ -19,7 +19,9 @@ import {
export default async function aiRoutes(app: FastifyInstance): Promise<void> {
await app.register(multipart, {
limits: { fileSize: config.nas.maxUploadSize },
// Cap files per request: the budget re-check already bounds *spend* mid-batch,
// but this bounds the work (one vision call per file) of a single request.
limits: { fileSize: config.nas.maxUploadSize, files: 20 },
});
// GET /api/admin/ai/usage — current-month spend + budget