feat: implement OpenAI Batch API for cost-efficient AI processing

- Add AIBatchRequest and AIRequestStatus models to Prisma schema
- Create comprehensive batch processing system (lib/batchProcessor.ts)
- Add intelligent batch scheduler with automated management
- Update processing pipeline to use batch requests instead of direct API calls
- Integrate batch scheduler into main server startup
- Achieve 50% cost reduction on OpenAI API usage
- Improve rate limiting and processing reliability
This commit is contained in:
2025-07-05 14:13:19 +02:00
committed by Kaj Kowalski
parent 5798988012
commit 8c8f360936
6 changed files with 1028 additions and 35 deletions

View File

@ -6,6 +6,7 @@ import { getSchedulerConfig, logEnvConfig, validateEnv } from "./lib/env.js";
import { startImportProcessingScheduler } from "./lib/importProcessor.js";
import { startProcessingScheduler } from "./lib/processingScheduler.js";
import { startCsvImportScheduler } from "./lib/scheduler.js";
import { startBatchScheduler } from "./lib/batchScheduler.js";
const dev = process.env.NODE_ENV !== "production";
const hostname = "localhost";
@ -33,6 +34,7 @@ app.prepare().then(() => {
startCsvImportScheduler();
startImportProcessingScheduler();
startProcessingScheduler();
startBatchScheduler();
console.log("All schedulers initialized successfully");
}