Comparison between CodiumAI PR Agent and GitHub CoPilot
Tags: ai, programming, productivity, opensource
Published: 2023-12-28 10:38:12

# Comparison between CodiumAI PR Agent to GitHub Copilot

## Introduction

We are now in the age of AI. New generations of coding assistants are now here with us.

AI tools are now like anabolic steroids. The developers using them get a huge advantage. If you are someone who loves to code like me, or a student learning how to code, you might feel a bit pessimistic right now.

All of our open source code, Stack Overflow answers, and tutorials have been used to build large language models that are now being aggressively deployed to automate white-collar jobs.

But, programming is not dead. Personally, I feel extremely grateful to be living through these times. In the next 30-40 years, we will be telling our grandkids how we were the first ones to start the great AI movement.

Resistance is futile. If you want to survive, you have to be optimistic. These tools will only make us more powerful.

AI still can't deliver a great product to the end user and will need programmers who understand how to build these systems, but now they will be able to build them 10 times faster, thanks to AI tooling.

It is a great time to be alive if you love building things.

Now, in the spirit of AI, we will look at Pull Requests and how you can do it with AI.

## What is a Pull Request

If you are new to web development, you have probably heard the term Pull Request but you are not sure what it means.

Pull request is a way for you to submit a contribution to another developers repository on Github.

You first have to find a GitHub repository that you want to contribute to. For this, we will create a repo from scratch and then use AI to do our Pull Requests.

In the process, we will do a demo to look at CodiumAI PR Agent and how it compares with GitHub Copilot to do Pull Requests.

## What is CodiumAI and GitHub Copilot

CodiumAI is a coding assistant that developers can use to enhance their coding experience using the power of Artificial Intelligence. It is a trending tool with features such as accurate code suggestions, explanation of the code, automatic test generation, and various language and IDE Support.

GitHub Copilot is also a coding assistant that was developed by GitHub in collaboration with OpenAI. It also has great features like easy autocomplete navigation, code suggestions and function generation.

Unlike GitHub Copilot, CodiumAI supports many Git platforms. You can use it with GitHub, Gitlab and BitBucket. With GitHub Copilot, you can only use it with GitHub.

For this demo, we are going to use CodiumAI to make a Pull Request.

## Installation

For the installation, we will need two things:

- OpenAI API Key
- GitHub Personal Access Token(Classic)

Now, let's get the OpenAI API Key.

## Getting OpenAI API Key

First, let's go to the Codium AI GitHub repository and follow the installation instructions.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzqsfe98wmntf1dqu5og.png)

To get started with PR-Agent quickly, you first need to acquire an OpenAI key with access to GPT-4. Let's do that.

Go to https://platform.openai.com/

You can then sign up

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yqe8nar4hm8puvtvdqf3.png)

After signing up, log in to OpenAI.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2le0ug7qpndwvxr81zli.png)

This will lead you to the Welcome page.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fzy5ykq1z7hzb2wuoi0y.png)

When you hover over the left side bar menu, you will see an padlock icon called API keys.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zbhlhzcbjn8erv96ctzh.png)

Click on it.

We will then create an API key. I already created mine as you can see.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h5g4g5idv6sdazt4rll9.png)

Click on the `Create new secret` key button.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xuif21hwp55v6birgifx.png)

Give your secret key a name. In my case, I will name it For CodiumAI. You can give it any name you like.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jygf0bb7l3gdm369y774.png)

You API key will be generated.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ou0a7hc54qivlyj23mgn.png)

Make sure to copy it somewhere. We are going to use it.

With CodiumAI, you can use many Git platforms like GitHub, Gitlab and Bitbucket. In comparison to GitHub Copilot, you can only use it with GitHub.

Also, the Codium PR-Agent is available both on Git and IDE not just Git.

In our case, we will use the Git version using GitHub.

We will need to get a GitHub personal access token(classic) since it is one of the two requirements of using Codium.

## Getting a GitHub Personal Access Token(Classic)

To get the GitHub Personal Access Token, lets head over to GitHub.

On the upper right corner, click on your profile picture then on `Settings`.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o5sfdzg9hflhr1xd4bc5.png)

In the left side bar, click on `Developer settings`

In the left side bar, under Personal Accecc Tokens, click on Tokens(classic).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/702crppmikh2qm1xu7pp.png)

Select `generate new token`, then `generate new token classic`

In the `Note` field, give your token a descriptive name.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zz2ppjpk7ajunxbtlly8.png)

To give your token an expiration, select `Expiration`, then choose a default option or click Custom to enter a date.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mvrxmuefnuux07dw9gp2.png)

Select the scopes you would like to grant this token.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1dti8ges28g7qgk1dsx.png)

Click the `Generate token` button.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a7e10j9yimwhpo65oz2l.png)

You can then copy the token somewhere for future reference.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w37w1lw0aa4xwnlcpk08.png)

## Adding the secret to our repository

Before adding our secret, we need to have a repository.

## Creating a new repository

So, let's go to GitHub and create a repository.

First login to GitHub.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p6d8jd9qba7d1q9fbng0.png)


Then create a new repository

![Alt text](image.png)

The name of our website will be `bakery website`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h7y3v33gn596zfkxdqfs.png)

It is a public repository. Incase you want to fork it, here is the link to it: https://github.com/KarlGusta/bakery-website 

## Now to adding our Secrets

Go to the repository that you have just created.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fws4gadpxxob9j5xs90x.png)

Click on `Settings` of the repository.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uygnhm6pj5hdhvjlecuo.png)

On the left side bar, click on Actions on the Secrets and Variables drop-down.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jxwho4fhuy5pf5f3ly3c.png)

Click on `New Repository Secret` button.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3dquxxyxe10fb4jrjic.png)

Here, we will add the Open AI key that we got from the OpenAI website.

For the name of the key, it is `OPENAI_KEY` Make sure you name it exactly that way.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50y7y6exk6iburuz9myd.png)

Click `Add Secret`

## Cloning our repo to our local computer

We will then clone it to our local computer.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/exat9ba2n989lvemcd2c.png)

Let's open it on VS Code.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iqqj2zjluoknjv97gamr.png)

We will create a simple `index.html` to use it for the demo.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/57zctn2susr4slhxi1kk.png)

I have added a title and a little description of it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d14rmfaxfkmp4t346ahs.png)

Let's see how it looks on the browser. I'm using a VS Code extension called `Live Server` to view my page.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1hj451e0i0hkqncp9k80.png)

Here is the page.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjc6kbs633iw02dfuicg.png)

Now, let's push our changes to GitHub.

## Adding GitHub Actions

We are going to use GitHub Actions.

To start lets create a `.github/workflows/pr_agent.yml` file to add the action.

Created the folder `.github` in VS Code by clicking the create folder icon.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgdlzfvs1gzqfrrquuif.png)

Next, lets create the workflows folder inside `.github` folder.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yik8ygibuq3d7srhuzn6.png)

Now, lets create the file `pr_agent.yml` inside the folder `workflows`.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d6kru4rtb2mlm9eb6i0m.png)

Inside the file, add this GitHub actions code.

```yml
on:
  pull_request:
  issue_comment:
jobs:
  pr_agent_job:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
      contents: write
    name: Run pr agent on every pull request, respond to user comments
    steps:
      - name: PR Agent action step
        id: pragent
        uses: Codium-ai/pr-agent@main
        env:
          OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1j8614k9k75lmhuhl3nv.png)

Now lets push the changes to GitHub.

On the main branch, commit and push to GitHub.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wuerbzdyvcuvcv791g2.png)

Now, to testing the Codium PR Agent GitHub action.

## Pushing changes to GitHub

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l050b301vnop5swee7ks.png)

The change has been pushed successfully as you can see.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ojg5mhy6x3l7wpg5ixv.png)

Now, let's a branch that we can use to test our Pull Requests.

## Creating a branch to test Pull Requests

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/to7jsu1sl3r6djlsncfm.png)

Call the branch `new branch` and press ENTER.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqmhcaqh0rtgpi4f76m2.png)

Now, let's make a few changes and publish it with the branch.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0e4a6pckyw1m56928met.png)

We now commit and push the new changes to GitHub. Notice we are on our new branch.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6ouf28cihzexgjj5657.png)

Click on `Yes`.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v7hrhnse3cfgs8v1elp8.png)

Now back to our repository on GitHub.

## Creating our first Pull Request

Let's compare and make our Pull Request. Click the button Compare & Pull Request.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yqjo3sxxqwp3r11xorb3.png)

On the description, you can say write this `Adding more content in the description` or anything.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1im0z9cwhjkrkpbtp9l8.png)

Then click the button `Create Pull Request`

Click the merge button.

Now, lets test how Codium PR Agent works.

## Testing how Codium PR Agent works

CodiumAI PR Agent supports many commands which we are going to look at today. For Codium, these include things like:

- Auto Description(/describe). This automatically generates the PR description. The title, type, summary, code walkthrough and labels.
- Auto Review(/review). Adjustable feedback about the PR main theme, type, relevant tests, security issues, score, and various suggestions for the PR content.
- Question Answering(/ask ...). Answering free-text questions about the PR.
- Code Suggestions(/improve). Committable code suggestions for improving the PR.
- Update Changelog(/update_changelog). Automatically updating the CHANGELOG.md file with the PR changes.
- Find Similar Issue(/similar_issue). Automatically retrieves and presents similar issues.
- Add Documentation(/add_docs). Automatically adds documentation to un-documented functions/classes in the PR.
- Generate Custom Labels(/generate_labels). Automatically suggests custom labels based on the PR code changes.

Let us test the Auto Review(/review) command.

## Testing the Auto Review command

After merging, under the comment section, write this command `@CodiumAI-Agent /review`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jsl5trtjnjv0zznz1bs.png)

Then click the button comment.

Codium PR Agent will do a review for you. Here it is.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nr7oeqn2ci0qzgys56i0.png)

The review is very descriptive and easy to understand.

It analyses the PR giving you information about the main theme. In our case, it is to enhance website content.

It also gives you a PR Summary, Type of PR, if there are any tests added, estimated effort to review the PR, any security concerns and PR feedback.

When we try the Code suggestions, it shows us how we can improve our code.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hmdrq3imvt3bxfa5h2ue.png)

You can test all the above commands to see how Codium can work to suit you best.

## GitHub CoPilot

At the moment, the only command that GitHub CoPilot supports for Pull Requests is the Pull request summaries.

With the Pull Request summaries is where it just gives you a summary of the changes made in the Pull Request, what files they impact, and what the person reviewing should focus on when they are doing their review.

This is only available to use for users of GitHub Copilot Enterprise.

CodiumAI PR Agent has the same command and many others which to me won the comparison between the two. GitHub has one command which can be found on CodiumAI PR Agent and it is open source.

## Conclusion

I hope this gives you a rough idea between the two AI tools.

See you soon in the next article. Happy Coding!