-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add embedding service with Xenova transformers for vector embeddings
Implement context service for code indexing and function mapping Configure embedding settings with batch processing and rate limiting Update code repository to separate table creation and data insertion Add @xenova/transformers dependency Refactor TypeScriptAtsMapper to use singleton pattern
- Loading branch information
1 parent
bc7b1f9
commit a9e9b75
Showing
9 changed files
with
369 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { EmbeddingService } from "./embedding-service"; | ||
import { APP_CONFIG } from "../application/constant"; | ||
import { IFunctionData } from "../application/interfaces"; | ||
import { getConfigValue } from "../application/utils"; | ||
import { Logger } from "../infrastructure/logger/logger"; | ||
import { CodeStructureMapper } from "./code-structure.mapper.service"; | ||
import { TypeScriptAtsMapper } from "./typescript-ats.service"; | ||
|
||
export class ContextService { | ||
logger: Logger; | ||
embeddingService: EmbeddingService; | ||
constructor() { | ||
this.logger = new Logger("ContextService"); | ||
const apiKey = this.getAPIKey(); | ||
this.embeddingService = new EmbeddingService(apiKey); | ||
} | ||
|
||
getAPIKey(): string { | ||
const { geminiKey } = APP_CONFIG; | ||
const apiKey = getConfigValue(geminiKey); | ||
if (!apiKey) { | ||
this.logger.info("Gemini API Key is required for code indexing"); | ||
throw new Error("Gemini API Key is required for code indexing"); | ||
} | ||
return apiKey; | ||
} | ||
|
||
async buildFunctionStructureMap() { | ||
const codeATS = TypeScriptAtsMapper.getInstance(); | ||
const mappedCode = await codeATS.buildCodebaseMap(); | ||
const ats = Object.values(mappedCode).flatMap((repo) => | ||
Object.values(repo.modules) | ||
); | ||
const mapper = new CodeStructureMapper(ats); | ||
return mapper.normalizeData(); | ||
} | ||
|
||
async generateFunctionDescription() { | ||
const functions = | ||
(await this.buildFunctionStructureMap()) as IFunctionData[]; | ||
return await this.embeddingService.processFunctions(functions); | ||
} | ||
|
||
// async generateContextEmbeddings | ||
} |
Oops, something went wrong.