Created
July 3, 2024 22:16
-
-
Save Ziggoto/56c1f9e957a160f32d168db958f58238 to your computer and use it in GitHub Desktop.
Simple code improver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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