Create a file in the root directory (the directory containing this file)
called .env and copy+paste the following content into it.
Replace values with your data as appropriate:
OPENAI_API_KEY="your-api-key-goes-here" OPENAI_MODEL_ID="gpt-4-1106-preview" NAME_OF_DEFAULT_GIT_BRANCH="remotes/origin/master" SHOW_TOKENS="false" DEFAULT_CONTEXT_FILES="baseContext.md"
To pr-check script requires some environmental variables
that tell it how to run. Without these, it can't run.
The pr-check script works by integrating with OpenAI's API.
To enable this integration, you must have an OpenAI API key.
Get an OpenAI key by creating an OpenAI account at www.openai.com
sample: OPENAI_API_KEY="your-api-key-goes-here"
The OpenAI API has different models, which different performance and price. Find out more here: https://platform.openai.com/docs/models
sample: OPENAI_MODEL_ID="gpt-4-1106-preview"
Determines whether or not the script will print to the console to show you how many tokens are contained in your OpenAI API prompt. The number of tokens determines the cost of the API usage, though different models have different costs associated with them.
sample: SHOW_TOKENS="false"
The pr-check script works by finding commits on your current branch
that are not on your 'master' branch. This is how the script compiles
a text of all the new changes you have made on your branch.
This gets a little tricky with regard to local and remote branchs. If you have rebased your checked out branch against remote master, but your local copy of master is not rebased against remote master, then your branch will have many commits that are not on your local copy of master, but which are not actually new commits you have made.
There are other similar problems too. For instance, you might not have a remote master yet. Or maybe your local master is actually ahead of your remote master.
Based on whatever best suits your situation, you need to specify the name of default branch against which your currently checked out branch will be compared. This will determine which commits on your checked out branch are 'new', and will be examined by the AI.
In most cases, 'remove/origin/master' is probably the right default branch to compare your branch against. This is the master branch on your remote repo (like github.com).
sample: NAME_OF_DEFAULT_GIT_BRANCH="remotes/origin/master"
You can define context files that will be referenced by OpenAI when reviewing your pull request.
Any document within the context file can be used as context.
When running the script, you'll be asked to specify which context
files to reference. Therefore, you can use different contexts for
reviewing different pull request.
You can select multiple context files to be used when reviewing any given PR. Here, you can specify a space seperated list of file names that will be considered the 'default' context files. When running the script, all the default context files will be pre-selected for use. You'll have to opt-out of not using them with the built-in checkbox mechanism.
By default, when downloading the pr_check repo, the context
directory is pre-populated with a baseContext.md file that
contains some basic directives for the AI to follow. You are
free to edit the contents of that file. However, these directives
are critical to how the AI knowing that it needs to perform a
PR review, so make sure that the base context contains the
information that the AI needs in order to function properly.
Here, specify a space seperated list of files that will be your default context files. So if you want two default context files, you would write DEFAULT_CONTEXT_FILES="fileOne.md fileTwo.md". If you specify a context file here that does not exist, an error will be thrown.
sample: DEFAULT_CONTEXT_FILES="baseContext.md"