diff --git a/src/components/admin/KnowledgeGraph.jsx b/src/components/admin/KnowledgeGraph.jsx index 200b624..87fd65e 100644 --- a/src/components/admin/KnowledgeGraph.jsx +++ b/src/components/admin/KnowledgeGraph.jsx @@ -235,9 +235,20 @@ const KnowledgeGraph = () => { const rawContent = await getFileContent('respellion', 'employee-handbook', file.path); await analyzeHandbookDelta(rawContent, file.path); await db.updateHandbookSyncState(file.path, file.sha); + + // To respect Anthropic's 5 requests per minute rate limit on this tier, + // we pause for 15 seconds before processing the next file. + if (count < filesToProcess.length) { + setSyncProgress(`Waiting 15s to avoid rate limits... (${count}/${filesToProcess.length})`); + await new Promise(resolve => setTimeout(resolve, 15000)); + } } catch (err) { console.error('Failed to process file:', file.path, err); - // We continue processing other files even if one fails + // We continue processing other files even if one fails, but still wait to avoid further rate limits + if (count < filesToProcess.length) { + setSyncProgress(`Error on ${file.name}. Waiting 15s... (${count}/${filesToProcess.length})`); + await new Promise(resolve => setTimeout(resolve, 15000)); + } } } setSyncProgress('Sync Complete!');