Skip to content

Commit 466f53f

Browse files
committed
Add public access modifier to async methods in Loz class
Make async methods in the Loz class public for better accessibility and maintainability. This change ensures that these methods can be accessed and utilized by other classes or modules when needed. Generated by gpt-3.5-turbo
1 parent ed2f8c4 commit 466f53f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/loz.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class Loz {
5757
this.chatHistoryManager = new ChatHistoryManager(dirPath);
5858
}
5959

60-
async init() {
60+
public async init() {
6161
if (checkGitRepo() === true) {
6262
if (!fs.existsSync(LOG_DEV_PATH)) {
6363
fs.mkdirSync(LOG_DEV_PATH);
@@ -115,7 +115,7 @@ export class Loz {
115115
return this.config.get("api")?.value;
116116
}
117117

118-
async completeUserPrompt(prompt: string) {
118+
public async completeUserPrompt(prompt: string) {
119119
let params: LLMSettings;
120120
params = this.defaultSettings;
121121
params.max_tokens = 500;
@@ -133,7 +133,7 @@ export class Loz {
133133
return completion;
134134
}
135135

136-
async runGitCommit() {
136+
public async runGitCommit() {
137137
let diff = await this.git.getDiffFromStaged();
138138

139139
// Remove the first line of the diff
@@ -176,7 +176,7 @@ export class Loz {
176176
}
177177

178178
// git diff | loz --git
179-
async generateGitCommitMessage(diff: string) {
179+
public async generateGitCommitMessage(diff: string) {
180180
if (DEBUG) console.log("writeGitCommitMessage");
181181
let params: LLMSettings;
182182
params = this.defaultSettings;
@@ -243,7 +243,7 @@ export class Loz {
243243
this.chatHistoryManager.addChat(promptAndCompleteText);
244244
}
245245

246-
runPromptInteractiveMode() {
246+
public runPromptInteractiveMode() {
247247
return new Promise((resolve, reject) => {
248248
let cli = new CommandLinePrompt(async (input: string) => {
249249
const tokens = input.split(" ");
@@ -287,24 +287,24 @@ export class Loz {
287287
}
288288
}
289289

290-
async handlePrompt(prompt: string) {
291-
const internPrompt =
290+
public async handlePrompt(prompt: string) {
291+
const systemPrompt =
292292
"Decide if the following prompt can be translated into Linux commands. " +
293293
"If yes, generate only the corresponding Linux commands in JSON format, assuming the current directory is '.'. " +
294294
"If no, provide an explanation in plain text.\n\n" +
295295
"Input: " +
296296
prompt +
297297
"\nResponse: ";
298298

299-
const completion = await this.completeUserPrompt(internPrompt + prompt);
299+
const completion = await this.completeUserPrompt(systemPrompt + prompt);
300300

301301
// If the completion is not a JSON object, but a plain text.
302302
if (!completion.content.startsWith("{")) {
303303
console.log(completion.content);
304304
const promptAndCompleteText = {
305305
mode: "regular mode",
306306
model: completion.model,
307-
prompt: internPrompt,
307+
prompt: systemPrompt,
308308
answer: completion.content,
309309
};
310310
this.chatHistoryManager.addChat(promptAndCompleteText);
@@ -331,7 +331,7 @@ export class Loz {
331331
const promptAndCompleteText = {
332332
mode: "command generation mode",
333333
model: completion.model,
334-
prompt: internPrompt,
334+
prompt: systemPrompt,
335335
answer: completion,
336336
};
337337
this.chatHistoryManager.addChat(promptAndCompleteText);
@@ -370,7 +370,7 @@ export class Loz {
370370
}
371371
}
372372

373-
close() {
373+
public close() {
374374
this.chatHistoryManager.saveChatHistory();
375375
}
376376
}

0 commit comments

Comments
 (0)