Skip to content

Commit 64baf88

Browse files
efraespadaactions-user
authored andcommitted
gh-action: updated compiled files
1 parent 98474e3 commit 64baf88

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

dist/index.js

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155927,20 +155927,26 @@ exports.Branches = Branches;
155927155927
/***/ }),
155928155928

155929155929
/***/ 2469:
155930-
/***/ ((__unused_webpack_module, exports) => {
155930+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
155931155931

155932155932
"use strict";
155933155933

155934155934
Object.defineProperty(exports, "__esModule", ({ value: true }));
155935155935
exports.ChunkedFile = void 0;
155936+
const crypto_1 = __nccwpck_require__(6113);
155936155937
class ChunkedFile {
155937155938
constructor(id, path, index, content, chunks) {
155939+
this.shasum = '';
155938155940
this.vector = [];
155939155941
this.id = id;
155940155942
this.path = path;
155941155943
this.index = index;
155942155944
this.content = content;
155943155945
this.chunks = chunks;
155946+
this.shasum = this.calculateShasum(content);
155947+
}
155948+
calculateShasum(content) {
155949+
return (0, crypto_1.createHash)('sha256').update(content).digest('hex');
155944155950
}
155945155951
}
155946155952
exports.ChunkedFile = ChunkedFile;
@@ -158040,6 +158046,10 @@ class DockerRepository {
158040158046
throw error;
158041158047
}
158042158048
};
158049+
this.getSystemInfo = async () => {
158050+
const response = await fetch('http://localhost:8000/system-info');
158051+
return await response.json();
158052+
};
158043158053
// const dockerHost = process.env.DOCKER_HOST;
158044158054
// if (dockerHost) {
158045158055
// this.docker = new Docker({ socketPath: dockerHost.replace('unix://', '') });
@@ -158221,6 +158231,24 @@ class FirestoreRepository {
158221158231
await Promise.all(parallelBatches.map(batch => this.processBatch(project, finalBranch, batch)));
158222158232
}
158223158233
};
158234+
this.setChunkedFile = async (project, branch, document) => {
158235+
const finalBranch = branch.replace(/\//g, '-');
158236+
const proyectCollection = (0, firestore_1.collection)(this.getFirestore(), project);
158237+
const branchDocument = (0, firestore_1.doc)(proyectCollection, finalBranch);
158238+
const filesCollection = (0, firestore_1.collection)(branchDocument, this.CHUNKS_COLLECTION);
158239+
const chunkDocument = (0, firestore_1.doc)(filesCollection, document.id);
158240+
await (0, firestore_1.setDoc)(chunkDocument, document);
158241+
};
158242+
this.getChunkedFiles = async (project, branch, shasum) => {
158243+
const finalBranch = branch.replace(/\//g, '-');
158244+
const proyectCollection = (0, firestore_1.collection)(this.getFirestore(), project);
158245+
const branchDocument = (0, firestore_1.doc)(proyectCollection, finalBranch);
158246+
const filesCollection = (0, firestore_1.collection)(branchDocument, this.CHUNKS_COLLECTION);
158247+
const shaQuery = (0, firestore_1.query)(filesCollection, (0, firestore_1.where)('shasum', '==', shasum));
158248+
const snapshot = await (0, firestore_1.getDocs)(shaQuery);
158249+
const documents = snapshot.docs.map(doc => doc.data());
158250+
return documents;
158251+
};
158224158252
this.config = config;
158225158253
}
158226158254
async processBatch(project, branch, documents) {
@@ -163820,8 +163848,12 @@ class VectorActionUseCase {
163820163848
}
163821163849
const firestoreRepository = new firestore_repository_1.FirestoreRepository(param.firebaseConfig);
163822163850
await this.dockerRepository.startContainer();
163851+
const systemInfo = await this.dockerRepository.getSystemInfo();
163852+
(0, logger_1.logDebugInfo)(`System info: ${JSON.stringify(systemInfo, null, 2)}`);
163853+
const chunkSize = systemInfo.parameters.chunk_size;
163854+
const maxWorkers = systemInfo.parameters.max_workers;
163823163855
(0, logger_1.logDebugInfo)(`Getting chunked files for ${param.repo} ${param.commit.branch}`);
163824-
const chunkedFiles = await this.fileRepository.getChunkedRepositoryContent(param.owner, param.repo, param.commit.branch, 32, param.tokens.token);
163856+
const chunkedFiles = await this.fileRepository.getChunkedRepositoryContent(param.owner, param.repo, param.commit.branch, chunkSize, param.tokens.token);
163825163857
(0, logger_1.logDebugInfo)(`Chunked files: ${chunkedFiles.length}`);
163826163858
const processedChunkedFiles = [];
163827163859
const totalFiles = chunkedFiles.length;
@@ -163835,12 +163867,16 @@ class VectorActionUseCase {
163835163867
const estimatedTotalTime = (elapsedTime / (i + 1)) * totalFiles;
163836163868
const remainingTime = estimatedTotalTime - elapsedTime;
163837163869
(0, logger_1.logDebugInfo)(`Processing file ${i + 1}/${totalFiles} (${progress.toFixed(1)}%) - Estimated time remaining: ${Math.ceil(remainingTime)} seconds`);
163870+
const remoteChunkedFiles = await firestoreRepository.getChunkedFiles(param.repo, param.commit.branch, chunkedFile.shasum);
163871+
if (remoteChunkedFiles.length > 0 && remoteChunkedFiles[0].vector.length > 0) {
163872+
processedChunkedFiles.push(chunkedFile);
163873+
continue;
163874+
}
163838163875
const embeddings = await this.dockerRepository.getEmbedding(chunkedFile.chunks.map(chunk => [this.CODE_INSTRUCTION, chunk]));
163839163876
chunkedFile.vector = embeddings;
163877+
await firestoreRepository.setChunkedFile(param.repo, param.commit.branch, chunkedFile);
163840163878
processedChunkedFiles.push(chunkedFile);
163841163879
}
163842-
(0, logger_1.logDebugInfo)(`Setting all chunked files to firestore for ${param.repo} ${param.commit.branch}`);
163843-
await firestoreRepository.setAllChunkedFiles(param.repo, param.commit.branch, processedChunkedFiles);
163844163880
(0, logger_1.logDebugInfo)(`All chunked files set to firestore for ${param.repo} ${param.commit.branch}`);
163845163881
results.push(new result_1.Result({
163846163882
id: this.taskId,

0 commit comments

Comments
 (0)