@@ -57,7 +57,7 @@ export class Loz {
57
57
this . chatHistoryManager = new ChatHistoryManager ( dirPath ) ;
58
58
}
59
59
60
- async init ( ) {
60
+ public async init ( ) {
61
61
if ( checkGitRepo ( ) === true ) {
62
62
if ( ! fs . existsSync ( LOG_DEV_PATH ) ) {
63
63
fs . mkdirSync ( LOG_DEV_PATH ) ;
@@ -115,7 +115,7 @@ export class Loz {
115
115
return this . config . get ( "api" ) ?. value ;
116
116
}
117
117
118
- async completeUserPrompt ( prompt : string ) {
118
+ public async completeUserPrompt ( prompt : string ) {
119
119
let params : LLMSettings ;
120
120
params = this . defaultSettings ;
121
121
params . max_tokens = 500 ;
@@ -133,7 +133,7 @@ export class Loz {
133
133
return completion ;
134
134
}
135
135
136
- async runGitCommit ( ) {
136
+ public async runGitCommit ( ) {
137
137
let diff = await this . git . getDiffFromStaged ( ) ;
138
138
139
139
// Remove the first line of the diff
@@ -176,7 +176,7 @@ export class Loz {
176
176
}
177
177
178
178
// git diff | loz --git
179
- async generateGitCommitMessage ( diff : string ) {
179
+ public async generateGitCommitMessage ( diff : string ) {
180
180
if ( DEBUG ) console . log ( "writeGitCommitMessage" ) ;
181
181
let params : LLMSettings ;
182
182
params = this . defaultSettings ;
@@ -243,7 +243,7 @@ export class Loz {
243
243
this . chatHistoryManager . addChat ( promptAndCompleteText ) ;
244
244
}
245
245
246
- runPromptInteractiveMode ( ) {
246
+ public runPromptInteractiveMode ( ) {
247
247
return new Promise ( ( resolve , reject ) => {
248
248
let cli = new CommandLinePrompt ( async ( input : string ) => {
249
249
const tokens = input . split ( " " ) ;
@@ -287,24 +287,24 @@ export class Loz {
287
287
}
288
288
}
289
289
290
- async handlePrompt ( prompt : string ) {
291
- const internPrompt =
290
+ public async handlePrompt ( prompt : string ) {
291
+ const systemPrompt =
292
292
"Decide if the following prompt can be translated into Linux commands. " +
293
293
"If yes, generate only the corresponding Linux commands in JSON format, assuming the current directory is '.'. " +
294
294
"If no, provide an explanation in plain text.\n\n" +
295
295
"Input: " +
296
296
prompt +
297
297
"\nResponse: " ;
298
298
299
- const completion = await this . completeUserPrompt ( internPrompt + prompt ) ;
299
+ const completion = await this . completeUserPrompt ( systemPrompt + prompt ) ;
300
300
301
301
// If the completion is not a JSON object, but a plain text.
302
302
if ( ! completion . content . startsWith ( "{" ) ) {
303
303
console . log ( completion . content ) ;
304
304
const promptAndCompleteText = {
305
305
mode : "regular mode" ,
306
306
model : completion . model ,
307
- prompt : internPrompt ,
307
+ prompt : systemPrompt ,
308
308
answer : completion . content ,
309
309
} ;
310
310
this . chatHistoryManager . addChat ( promptAndCompleteText ) ;
@@ -331,7 +331,7 @@ export class Loz {
331
331
const promptAndCompleteText = {
332
332
mode : "command generation mode" ,
333
333
model : completion . model ,
334
- prompt : internPrompt ,
334
+ prompt : systemPrompt ,
335
335
answer : completion ,
336
336
} ;
337
337
this . chatHistoryManager . addChat ( promptAndCompleteText ) ;
@@ -370,7 +370,7 @@ export class Loz {
370
370
}
371
371
}
372
372
373
- close ( ) {
373
+ public close ( ) {
374
374
this . chatHistoryManager . saveChatHistory ( ) ;
375
375
}
376
376
}
0 commit comments