Skip to content

Commit

Permalink
Passing language to assistant code completion
Browse files Browse the repository at this point in the history
  • Loading branch information
codemakerai-dev committed Jul 2, 2024
1 parent 1b3e583 commit e8fef82
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/service/codemakerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class CodemakerService {
* @returns
*/
public async assistantCompletion(message: string) {
const language = Configuration.assistantLanguage();
return this.getClient().assistantCompletion(this.createAssistantCompletionRequest(message, language));
const textLanguage = Configuration.assistantLanguage();
return this.getClient().assistantCompletion(this.createAssistantCompletionRequest(message, textLanguage));
}

/**
Expand All @@ -109,14 +109,15 @@ class CodemakerService {
* @returns
*/
public async assistantCodeCompletion(message: string, path: vscode.Uri) {
const textLanguage = Configuration.assistantLanguage();
const model = Configuration.model();

const language = languageFromFile(path.path);
const source = await this.readFile(path);

const contextId = await this.registerContext(language, path);

const response = await this.getClient().assistantCodeCompletion(this.createAssistantCodeCompletionRequest(message, language, source, contextId, model));
const response = await this.getClient().assistantCodeCompletion(this.createAssistantCodeCompletionRequest(message, language, source, contextId, model, textLanguage));

if (response.output.source !== null && response.output.source.length !== 0) {
const output = response.output.source;
Expand Down Expand Up @@ -444,7 +445,7 @@ class CodemakerService {
};
}

private createAssistantCodeCompletionRequest(message: string, language: Language, source: string, contextId?: string, model?: string): AssistantCodeCompletionRequest {
private createAssistantCodeCompletionRequest(message: string, language: Language, source: string, contextId?: string, model?: string, textLanguage?: LanguageCode): AssistantCodeCompletionRequest {
return {
message,
language,
Expand All @@ -453,7 +454,8 @@ class CodemakerService {
},
options: {
contextId,
model
model,
language: textLanguage
}
};
}
Expand Down

0 comments on commit e8fef82

Please sign in to comment.