Skip to content

Commit

Permalink
Refactor handleInputFromPipe function for better organization
Browse files Browse the repository at this point in the history
Move the handleInputFromPipe function to a more appropriate location in the code for better organization and readability. This change separates the interactive mode logic from the input handling logic, improving the overall structure of the codebase.

Generated by gpt-3.5-turbo
  • Loading branch information
joone committed Mar 8, 2024
1 parent d07aee9 commit f67d270
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,15 @@ async function handlePrompt(prompt: any) {
loz.close();
}

async function handleInputFromPipe(prompt: any) {
// Handle the input from the pipe
process.stdin.setEncoding("utf8");
process.stdin.on("data", async (data: String) => {
const promptUpdated =
"Based on the data provided below, " + prompt + ":\n" + data;
const completion = await loz.completeUserPrompt(promptUpdated);
process.stdout.write(completion.content);
process.stdout.write("\n");
});
async function handleInteractiveMode() {
console.log("Loz: a simple CLI for LLM");
try {
await loz.runPromptInteractiveMode();
} catch (error) {
console.log(error);
}
console.log("Good bye!");
loz.close();
}

async function handleCodeDiffFromPipe() {
Expand Down Expand Up @@ -96,15 +95,16 @@ async function handleCodeDiffFromPipe() {
});
}

async function handleInteractiveMode() {
console.log("Loz: a simple CLI for LLM");
try {
await loz.runPromptInteractiveMode();
} catch (error) {
console.log(error);
}
console.log("Good bye!");
loz.close();
async function handleInputFromPipe(prompt: any) {
// Handle the input from the pipe
process.stdin.setEncoding("utf8");
process.stdin.on("data", async (data: String) => {
const promptUpdated =
"Based on the data provided below, " + prompt + ":\n" + data;
const completion = await loz.completeUserPrompt(promptUpdated);
process.stdout.write(completion.content);
process.stdout.write("\n");
});
}

(async () => {
Expand Down

0 comments on commit f67d270

Please sign in to comment.