Optimize all AI functions for efficiency and speed

- AI Tagging: batch 10 projects per API call with 3 concurrent batches (~10x faster)
  - New `tagProjectsBatch()` with `getAISuggestionsBatch()` for multi-project prompts
  - Single DB query for all projects, single anonymization pass
  - Compact JSON in prompts (no pretty-print) saves tokens
- AI Shortlist: run STARTUP and BUSINESS_CONCEPT categories in parallel (2x faster)
- AI Filtering: increase default parallel batches from 1 to 3 (3x faster)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt
2026-02-16 14:02:38 +01:00
parent 989db4dc14
commit 65a22e6f19
4 changed files with 377 additions and 49 deletions

View File

@@ -344,8 +344,8 @@ export async function generateShortlist(
let totalTokens = 0
const allErrors: string[] = []
// Run each category independently
for (const cat of categories) {
// Run categories in parallel for efficiency
const categoryPromises = categories.map(async (cat) => {
const catTopN = cat === 'STARTUP'
? (startupTopN ?? topN)
: (conceptTopN ?? topN)
@@ -357,6 +357,12 @@ export async function generateShortlist(
prisma,
)
return { cat, result }
})
const categoryResults = await Promise.all(categoryPromises)
for (const { cat, result } of categoryResults) {
if (cat === 'STARTUP') {
allRecommendations.STARTUP = result.recommendations
} else {