Skip to content

Instantly share code, notes, and snippets.

@Ziggoto
Created July 3, 2024 22:16
Show Gist options
  • Save Ziggoto/56c1f9e957a160f32d168db958f58238 to your computer and use it in GitHub Desktop.
Save Ziggoto/56c1f9e957a160f32d168db958f58238 to your computer and use it in GitHub Desktop.
Simple code improver
import ollama from "ollama";
import fs from "fs";
const systemRole = `You are a senior software Engineer who is very picky with code-quality. You have read and memorised Clean Code from Robert Cecil Martin. Your goal is to read other people's code and improve then based on what you learned with that book.`;
const [, , fileToBeImproved] = process.argv;
if (fileToBeImproved) {
const fileContent = fs.readFileSync(fileToBeImproved, { encoding: "utf8" });
const response = await ollama.chat({
model: "llama3:latest",
messages: [
{ role: "system", content: systemRole },
{ role: "user", content: fileContent },
],
});
console.log(response.message.content);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment