@@ -6,8 +6,8 @@ const path = require('path');
66// Configuration constants
77const MAX_TOKENS_PER_REQUEST = 100000 ; // Conservative limit for Gemini 2.5 Flash
88const CHARS_PER_TOKEN = 4 ; // Rough estimation
9- const MAX_CHARS_PER_CHUNK = MAX_TOKENS_PER_REQUEST * CHARS_PER_TOKEN ;
10- const MAX_CHUNKS = 1 ; // Limit to prevent excessive API calls
9+ // const MAX_CHARS_PER_CHUNK = MAX_TOKENS_PER_REQUEST * CHARS_PER_TOKEN;
10+ const MAX_CHUNKS = 3 ; // Limit to prevent excessive API calls
1111
1212/**
1313 * Estimate token count for text (rough approximation)
@@ -183,7 +183,7 @@ async function processChunks(chunks, apiKey) {
183183 if ( chunkResults . length === 0 ) {
184184 throw new Error ( 'Failed to process any chunks' ) ;
185185 }
186-
186+ sleep ( 3 * 1000 ) ;
187187 // Combine results from multiple chunks
188188 const combinedPrompt = `Combine these pull request descriptions into a single, coherent PR description. Use the same format:
189189
@@ -225,41 +225,13 @@ Create a unified description that captures the overall changes across all files.
225225 console . error ( 'Large diff detected, using chunking strategy...' ) ;
226226
227227 // For extremely large diffs, first try to summarize
228- if ( estimatedTokens > MAX_TOKENS_PER_REQUEST * 5 ) {
229- console . error ( 'Extremely large diff detected, using summary approach...' ) ;
230- const summaryPrompt = createSummaryPrompt ( diffContent ) ;
231- result = await callGeminiAPI ( summaryPrompt , apiKey ) ;
232-
233- // Create a simplified PR description based on the summary
234- const prPrompt = `Based on this summary of changes, create a pull request description using this format:
235-
236- ## Description
237- Brief summary of changes (1-2 sentences max).
238-
239- ## Changes
240- - [ ] Key change 1
241- - [ ] Key change 2
242- - [ ] Key change 3 (max 5 items)
243-
244- ## Verification
245- - [ ] Test step 1
246- - [ ] Test step 2
247- - [ ] Test step 3 (max 3 items)
248-
249- Summary: ${ result } ` ;
250-
251- result = await callGeminiAPI ( prPrompt , apiKey ) ;
252- } else {
253- // Chunk the diff and process
254- const chunks = chunkDiffByFiles ( diffContent ) ;
255- console . error ( `Split diff into ${ chunks . length } chunks` ) ;
256-
257- if ( chunks . length > MAX_CHUNKS ) {
258- console . error ( `Warning: Too many chunks (${ chunks . length } ), processing first ${ MAX_CHUNKS } chunks only` ) ;
259- }
260-
261- result = await processChunks ( chunks , apiKey ) ;
228+ console . error ( 'Extremely large diff detected, using summary approach...' ) ;
229+ const chunks = chunkDiffByFiles ( diffContent ) ;
230+ console . error ( `Split diff into ${ chunks . length } chunks` ) ;
231+ if ( chunks . length > MAX_CHUNKS ) {
232+ console . error ( `Warning: Too many chunks (${ chunks . length } ), processing first ${ MAX_CHUNKS } chunks only` ) ;
262233 }
234+ result = await processChunks ( chunks , apiKey ) ;
263235 } else {
264236 // Small diff, process normally
265237 result = await callGeminiAPI ( createPRPrompt ( diffContent ) , apiKey ) ;
0 commit comments