Spell Checker
Automating and improving the efficiency of proofreading documents is a common need among developers and writers. This script addresses this need by checking and correcting spelling and grammar in Markdown files.
Code Explanation
Starting at the top of the script, we see that it’s a GenAI script, which is evident from the .mts
extension and the script
function call.
This block sets the title of the script to “Spell checker” and specifies that it uses several system prompts, such as file operations and diff generation. The temperature
is set to 0.1
, indicating that the script will generate output with low creativity, thus favoring precision.
Defining the File Types to Work on
Following this, there’s a def
call:
This line defines FILES
to be the array of files we gathered.
The $
-prefixed backtick notation is used to write the prompt template:
How to Run the Script with GenAIScript CLI
Running this spell checker script is straightforward with the GenAIScript CLI. First, ensure you have the CLI installed by following the instructions in the GenAIScript documentation.
Once you have the CLI installed, navigate to your local copy of the script in your terminal or command line interface. Run the following command to execute the spell checker:
Remember, you do not need to specify the .genai.mts
extension when using the convert
command.
And there you have it—a detailed walkthrough of a GenAI spell checker script for markdown files. Happy coding and perfecting your documents!
Full source (GitHub)
Content Safety
The following measures are taken to ensure the safety of the generated content.
- This script includes system prompts to prevent prompt injection and harmful content generation.
- The generated description is saved to a file at a specific path, which allows for a manual review before committing the changes.
Additional measures to further enhance safety would be to run a model with a safety filter or validate the message with a content safety service.
Refer to the Transparency Note for more information on content safety.