Skip to content

Commit

Permalink
build: Fixed LLM throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
mmiscool committed Jan 23, 2025
1 parent 45f4480 commit eb8dc73
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
6 changes: 5 additions & 1 deletion src/llmCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ async function throttle() {
const currentTime = new Date().getTime();
if (currentTime < lastCallTime + throttleTime * 1000) {
const remainingTime = (lastCallTime + throttleTime) - currentTime;
await printAndPause(`Throttling. Please wait ${remainingTime / 1000} seconds.`, remainingTime / 1000);
await printAndPause(`Throttling. Please wait ${remainingTime / 1000} seconds.`);
// wait for the remaining time
await new Promise((resolve) => {
setTimeout(resolve, remainingTime);
});
}

lastCallTime = new Date().getTime();
Expand Down
38 changes: 27 additions & 11 deletions src/mergeTools/languages/javascript/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as escodegen from 'escodegen';
import esprima from 'esprima-next';
import estraverse from 'estraverse';

const debug = false;
const debug = true;


export class javascriptManipulator {
Expand Down Expand Up @@ -34,16 +34,32 @@ export class javascriptManipulator {
return await this.generateCode();
}
async mergeDuplicates() {
await this.parse();
await this.cleanUpComments();
await this.makeAllFunctionsExported();
await this.makeAllClassesExported();
await this.mergeDuplicateImports();
await this.mergeDuplicateVariables();
await this.mergeDuplicateFunctions();
await this.mergeDuplicateClasses();
await this.removeEmptyExports();
return await this.generateCode();
try {
await this.parse();
console.log('parsed');
await this.cleanUpComments();
console.log('cleaned up comments');
await this.makeAllFunctionsExported();
console.log('made all functions exported');
await this.makeAllClassesExported();
console.log('made all classes exported');
await this.mergeDuplicateImports();
console.log('merged duplicate imports');
await this.mergeDuplicateVariables();
console.log('merged duplicate variables');
await this.mergeDuplicateFunctions();
console.log('merged duplicate functions');
await this.mergeDuplicateClasses();
console.log('merged duplicate classes');
await this.removeEmptyExports();
console.log('removed empty exports');
return await this.generateCode();
} catch (e) {
console.error(e);
debugLog('Error parsing the new code snippet');
return false;
}

}
async removeEmptyExports() {
// Remove empty export statements
Expand Down

0 comments on commit eb8dc73

Please sign in to comment.