diff --git a/src/helpers/completion.ts b/src/helpers/completion.ts index c4a9c65..6306280 100644 --- a/src/helpers/completion.ts +++ b/src/helpers/completion.ts @@ -15,7 +15,7 @@ const explainInSecondRequest = true; function getOpenAi(key: string, apiEndpoint: string) { const openAi = new OpenAIApi( - new Configuration({ apiKey: key, basePath: apiEndpoint }) + new Configuration({ apiKey: key, basePath: apiEndpoint }), ); return openAi; } @@ -74,7 +74,7 @@ export async function generateCompletion({ n: Math.min(number, 10), stream: true, }, - { responseType: 'stream' } + { responseType: 'stream' }, ); return completion.data as unknown as IncomingMessage; @@ -83,7 +83,7 @@ export async function generateCompletion({ if (error.code === 'ENOTFOUND') { throw new KnownError( - `Error connecting to ${error.request.hostname} (${error.request.syscall}). Are you connected to the internet?` + `Error connecting to ${error.request.hostname} (${error.request.syscall}). Are you connected to the internet?`, ); } @@ -91,7 +91,7 @@ export async function generateCompletion({ let message = response?.data as string | object | IncomingMessage; if (response && message instanceof IncomingMessage) { message = await streamToString( - response.data as unknown as IncomingMessage + response.data as unknown as IncomingMessage, ); try { // Handle if the message is JSON. It should be but occasionally will @@ -114,7 +114,7 @@ export async function generateCompletion({ ` + '\n\n' + messageString + - '\n' + '\n', ); } else if (response && message) { throw new KnownError( @@ -123,7 +123,7 @@ export async function generateCompletion({ ` + '\n\n' + messageString + - '\n' + '\n', ); } @@ -191,11 +191,10 @@ export const readData = const rl = readline.createInterface({ input: process.stdin, }); - + rl.input.setRawMode(true); - + rl.input.on('keypress', (key) => { - if (typeof key === 'string' && key.toLowerCase().includes('q')) { stopWriting = true; } @@ -237,7 +236,7 @@ export const readData = if (dataStart && content) { const contentWithoutExcluded = stripRegexPatterns( content, - excluded + excluded, ); data += contentWithoutExcluded;