This project provides a service for analyzing GitHub Pull Requests (PRs) using Azure's deployed GPT-4-o-mini model. The primary goal is to process and analyze PR changes programmatically to assist developers with code reviews, suggestions, or understanding complex PRs more effectively. The service is accessible via an API backend.
The project employs the following approach:
-
Prompt Engineering: The service constructs a prompt for the GPT-4-o-mini model using the changes from a GitHub Pull Request. This prompt is designed to guide the model to analyze the PR and provide meaningful insights or feedback.
-
Task Management: Celery and Redis are used to queue and manage tasks for efficient processing, ensuring scalability and robustness.
-
API Endpoints:
- Submit a PR for analysis.
- Check the status of an analysis task.
- Retrieve the results of an analysis task.
-
Deployed Service: The application is deployed at
https://githubpragent-production.up.railway.app/docsfor easy access. Users can also run it locally or via Docker.
- Analyze both public and private repositories (requires GitHub token for private repositories).
- Track the status of analysis tasks.
- Retrieve detailed insights on the analyzed Pull Request.
- User-friendly API documentation available at
/docs.
The service is deployed at https://githubpragent-production.up.railway.app/docs.
-
Visit
https://githubpragent-production.up.railway.app/docsto explore the API documentation. -
Submit a POST request to the
/analyze-prendpoint with the following example JSON:{ "repo_url": "https://github.com/your/repo", "pr_number": 123, "github_token": "your_personal_access_token(optional_for_public_repos)" }- Replace
repo_url,pr_number, andgithub_tokenwith your specific values. - The
github_tokenis optional for public repositories.
- Replace
-
Use the returned
task_idto:- Check task status:
/status/{task_id} - Retrieve task results:
/results/{task_id}
- Check task status:
git clone https://github.com/varunchopra11/githubPrAgent.git
cd githubPrAgentCreate a virtual environment and install the required dependencies:
python -m venv myenv
source myenv/bin/activate # Use myenv\Scripts\activate on Windows
pip install -r requirements.txtpython -m app.mainAccess the service at http://localhost:8000/docs.
Setup .env file in project's root directory.
docker build -t githubagent .docker run -d -p 8000:8000 --env-file .env githubagentThis setup ensures that your project runs with environment variables from the .env file and binds to port 8000. Access the service at http://localhost:8000/docs.
The application uses environment variables defined in a .env file for configuration. Ensure your .env file includes:
AZURE_ENDPOINT=<your_azure_endpoint>
AZURE_API_KEY=<your_azure_api_key>
REDIS_URL=<your_redis_url>
-
Analyze PR:
POST /analyze-pr- Input: Repository URL, PR number, optional GitHub token.
- Output:
task_idfor tracking analysis.
-
Get Task Status:
GET /status/{task_id}- Input:
task_id - Output: Current status of the analysis task.
- Input:
-
Get Task Results:
GET /results/{task_id}- Input:
task_id - Output: Results of the analysis.
- Input:
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please fork the repository and submit a pull request with your proposed changes.