
Tutorial
Building an AI Article Reviewer using GenAI Platform and GitHub
Introduction
For those who write either professionally or as a hobby, it’s clear that personal writing can follow any structure. However, professional writing typically requires adherence to certain style guides and a review process before publication. This tutorial is aimed at individuals who use GitHub for their workflows and want to expedite the review process using AI. You will learn to create a GitHub action that is trained on your writing and style guidelines to identify issues in your text and suggest improvements.
Prerequisites
To follow along, you should have:
- Basic knowledge of YAML to construct the GitHub Action.
- Familiarity with JavaScript.
- A DigitalOcean account to access the GenAI platform for training the GitHub Action.
The problem and how to solve it
Review processes are often time-consuming and typically involve manual checks. This can lead to longer delays, especially during busy periods. By harnessing AI trained on your style guides, you can create a GitHub action that rapidly identifies writing issues and provides suggestions. This can transform the review timeline from days to mere seconds.
The GitHub action you will create is already available in the marketplace, which means you can utilize it directly in your repositories after training it on your specific data. The process consists of two key steps:
- Deploying a DigitalOcean GenAI agent that is trained using your style guides.
- Adding a workflow file to your repository to implement the GitHub action.
Building the DigitalOcean GenAI Agent
To set up the GenAI agent that reviews your markdown files, you will need to create and index a knowledge base on your tutorials.
- Log in to DigitalOcean and access the GenAI platform.
- Under the ‘Knowledge bases’ tab, select ‘Create Knowledge Base’.
- Name your knowledge base and choose the data source option for web crawling.
- Opt for the ‘Subdomains’ setting to achieve the widest possible crawl of your documents. Choose an embedding model and then create the knowledge base.
Once the knowledge base is created, proceed to create an agent by selecting the ‘Create agent’ option in the GenAI platform. Provide a name and a prompt for the agent, such as:
Your task is to check for grammatical errors in an article. Use the knowledge base to learn the writing style and check for:- Typos, punctuation errors, and incorrect sentence structures.- Active voice usage and avoidance of passive constructions where possible.- H tags and trailing spaces.
After creating the agent, go to the Playground and input a markdown file that contains incorrect grammar or structure. The agent should then generate suggestions for improvements.
Using the GitHub Action
With the AI agent ready, the next step is to implement the GitHub Action into your repository:
- Copy the agent endpoint and create a key from the
Settings
tab. - In your repository settings, under ‘Actions’, input the endpoint and key.
- In the workflow folder of your repository, create a
.yml
file, such as.github/workflows/grammar-check.yml
, and add the following code:
name: Check Markdown Grammaron: pull_request: types: [opened, synchronize, reopened] paths: - '**.md' workflow_dispatch:jobs: check-markdown: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Get changed files id: changed-files uses: dorny/paths-filter@v2 with: filters: | markdown: - '**/*.md' - '!**/node_modules/**' - name: Check Markdown Grammar if: steps.changed-files.outputs.markdown == 'true' uses: Haimantika/article-review-github-action@v1.1.1 with: do-api-token: ${{ secrets.DO_API_TOKEN }} do-agent-base-url: ${{ secrets.DO_AGENT_BASE_URL }} file-pattern: ${{ steps.changed-files.outputs.files_markdown }} exclude-pattern: '**/node_modules/**,**/vendor/**'
- To test the action, create a pull request with a markdown file, triggering the check. The action will fail if issues are detected.
Building Your Own GitHub Action
You’ll want to create a workflow file that automatically prompts the action upon a pull request. The script should utilize a grammar-checker.js
file to evaluate the markdown file(s) for grammar and style issues.
This will involve implementing a process to check all markdown files within the repository, sending text for grammar checking, and logging any found issues.
Conclusion
In this tutorial, we’ve explored how to build a sophisticated AI article reviewer using DigitalOcean’s GenAI Platform combined with GitHub Actions. By employing AI technology, you can significantly enhance the efficiency of your technical writing review processes by rapidly identifying errors and making recommendations in alignment with your organization’s style.
Welcome to DediRock, your trusted partner in high-performance hosting solutions. At DediRock, we specialize in providing dedicated servers, VPS hosting, and cloud services tailored to meet the unique needs of businesses and individuals alike. Our mission is to deliver reliable, scalable, and secure hosting solutions that empower our clients to achieve their digital goals. With a commitment to exceptional customer support, cutting-edge technology, and robust infrastructure, DediRock stands out as a leader in the hosting industry. Join us and experience the difference that dedicated service and unwavering reliability can make for your online presence. Launch our website.