Package: review-bot
OverviewThereview-botpackage is a Python development tool for leveraging
the power of OpenAI to automatically generate suggestions for improving
GitHub pull requests. To generate suggestions for improvements, this tool
considers code style, logical errors, and other possible issues. Using
this tool makes the code review process smoother and more efficient,
ensuring that your code base is high quality, easy to maintain, and
adheres to best practices.Install thereview-botpackage with this command:pipinstallreview-botInstallationTwo installation modes are provided: user and developer.For usersFirst, to make sure that you have the latest version ofpip,
run this command:python-mpipinstall-UpipThen, to install thereview-botpackage, run this command:python-mpipinstallreview-botToken configurationTo use this tool to review GitHub pull requests, you must have two tokens for
accessing the bot functionalities:GitHub access tokenAzure OpenAI tokenSubsequent sections explain how to obtain these tokens and set them up for your project.Ensure that you keep your tokens confidential and do not share them publicly. Additionally,
always follow the best security practices to protect your project and data from unauthorized
access.GitHub access tokenA GitHub access token is required to access the GitHub API for certain features, such as
querying repositories, creating issues, and managing pull requests.To obtain a GitHub access token, perform these steps:Create a GitHub account:If you do not already have a GitHub account, sign up for one
athttps://github.com/signup.Generate a PAT (personal access token):After signing into your GitHub account, go toPersonal access tokens (classic)in your GitHub
developer settings and click theGenerate a personal access tokenlink. Follow
the prompts to configure your new token, choosing the scope of access required based on
your project’s needs.Copy the token:After creating the token, GitHub displays it only once. Make sure
that you copy the token to a secure location because you are not able to see it again.Set the token as an environment variable:To use the project with your GitHub access
token, set the token as an environment variable having this name:GITHUB_TOKEN.Azure OpenAI tokenThe Azure OpenAI token is required to access the OpenAI API for utilizing the advanced AI
capabilities provided byMicrosoft Azure.To obtain an Azure OpenAI token, perform these steps:Sign up for Azure:If you do not already have an Azure account, sign up for a free
account athttps://azure.com/free.Create an OpenAI resource:Once you have an Azure account, create an OpenAI resource
in the Azure portal. This resource provides you with the necessary credentials to access
the OpenAI API.Copy the token:After creating the resource, Azure sends you a token (key) that
grants you access to the OpenAI services. Make sure that you copy this token to a
secure location.Set the token as an environment variable:To use the project with your Azure OpenAI
token, set the token as an environment variable having this name:OPEN_AI_TOKEN.Additional required environment variablesIn addition to setting up environment variables for the GitHub access token and Azure OpenAI
token, you must set up some additional environment variables to customize the behavior of the
OpenAI project. The following variables allow you to fine tune various aspects of the OpenAI
model and the OpenAI API integration.OPENAI_API_BASEDescription: Specifies the base URL of the OpenAI Azure API. This environment variable
allows you to set the API endpoint for making requests to the OpenAI services.Example:https://your-api-name.openai.azure.comOPENAI_API_TYPEDescription: Defines the type of the OpenAI API. This environment variable is used to
specify that you are using the Azure version of OpenAI.Example:azureOPENAI_API_VERSIONDescription: Indicates the version of the OpenAI API to use. This environment variable
ensures compatibility with the specific version of the AI model.Example:2023-05-15OPENAI_MODELDescription: Allows you to select a particular AI model or engine provided by your
Azure OpenAI deployment. You can check your deployment to see the names of your models.
Different models may have varying capabilities and performance.Example:gpt-3.5-turbo-franceortext-davinci-002With all these environment variables properly configured, you are ready to leverage the full
potential of the review bot.Optionally, if you are using the review bot through CLI locally, you can set the Azure OpenAI
variables in a JSON configuration file as per this example:{"OPEN_AI_TOKEN":"your-token","OPENAI_MODEL":"gpt-4","OPENAI_API_BASE":"https://your-api-base.openai.azure.com/","OPENAI_API_VERSION":"2023-03-15-preview","OPENAI_API_TYPE":"azure"}CLI usageTo use the CLI (command-line interface) of the review bot, run this command:reviewbot<-rpath-to-repo>[-cpath-to-openai-config]pre-commitThe style checks take advantage ofpre-commit. Developers are encouraged to
install this tool by running this command:python-mpipinstallpre-commit&&pre-commitinstall