Skip to content

Commit

Permalink
Fix Identation
Browse files Browse the repository at this point in the history
  • Loading branch information
thelastmayday committed Feb 2, 2024
1 parent dc1943f commit c3c287d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/helpers/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -83,15 +83,15 @@ 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?`,
);
}

const response = error.response;
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
Expand All @@ -114,7 +114,7 @@ export async function generateCompletion({
` +
'\n\n' +
messageString +
'\n'
'\n',
);
} else if (response && message) {
throw new KnownError(
Expand All @@ -123,7 +123,7 @@ export async function generateCompletion({
` +
'\n\n' +
messageString +
'\n'
'\n',
);
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -237,7 +236,7 @@ export const readData =
if (dataStart && content) {
const contentWithoutExcluded = stripRegexPatterns(
content,
excluded
excluded,
);

data += contentWithoutExcluded;
Expand Down

0 comments on commit c3c287d

Please sign in to comment.