
The aim of this project is to take any given python
code in a repository and analyze it via a chatbot using
OpenAI models and Langchain API.
Report Bug
·
Request Feature
Table of Contents
In this project, we have leveraged the capabilities of OpenAI models and Langchain API to analyze the source code of a given Python repository. The application allows users to input the URL of a GitHub repository containing Python code and receive detailed insights and analysis via a chatbot interface. The chatbot interacts with the user, providing information on the code structure, functions, variables, and potential improvements. This project aims to simplify the process of code analysis and provide valuable feedback to developers, educators, and learners. By utilizing advanced natural language processing (NLP) models, the application can extract key information from the code and generate meaningful insights for the user.
The user can interact with the chatbot to ask questions about the code, understand its functionality, and receive suggestions for optimization. The chatbot uses OpenAI models to process the user's queries and provide accurate responses based on the code analysis. The Langchain API is used to extract relevant information from the code and generate insights that can help improve the code quality and performance. The application is designed to be user-friendly and intuitive, allowing users to easily input the GitHub repository URL and receive detailed analysis results in real-time.
Along with that, the user can enter "clear" to delete the previous repository and enter a new database and cloned repository. With this, the user can analyze multiple repositories in a single session. The chatbot provides a conversational interface that guides the user through the code analysis process and helps them understand the code structure, logic, and potential areas for improvement. The application is designed to be interactive, informative, and engaging, making it an ideal tool for developers, educators, and learners who want to gain insights into Python code and enhance their programming skills.
The application is deployed via AWS EC2 instance. That can be achieved by following the steps below:
-
Create an AWS EC2 Instance:
- Launch an EC2 instance with the desired configuration.
- Ensure that the security group associated with the instance allows inbound traffic on port 8501 (Streamlit default port).
-
SSH into the EC2 Instance:
- Use the SSH key pair associated with the EC2 instance to connect to the instance.
-
Install Required Packages:
- Install the necessary packages and dependencies on the EC2 instance.
- Ensure that Python, Streamlit, and other required libraries are installed.
- It can be done using the following commands:
sudo apt-get update
sudo apt upgrade -y
sudo apt install python3-pip git curl unzip tar make sudo vim wget -y
git clone "Your-repository"
cd "Your-repository"
pip3 install -r requirements.txt
-
Initialize the OPENAI API Key:
- Set up the OpenAI API key on the EC2 instance.
- Create a
.env
file in the project directory and add the OpenAI API key. - The
.env
file should contain the following line:
OPENAI_API_KEY=your_openai_api_key
-
Run the Streamlit Application:
- Run the Streamlit application on the EC2 instance.
- Use the following command to start the Streamlit server:
python3 app.py
-
Access the Application:
- Access the Streamlit application by visiting the public IP address of the EC2 instance followed by port 8501.
- The application should be accessible via a web browser.
- The URL format is as follows:
http://"Your-EC2-Public-IP":8501
The application should now be up and running on the AWS EC2 instance, allowing users to generate quiz questions from text or PDF documents. The screenshots for the instance are shown below:
I'm thrilled to have you exploring my project! This endeavor is a collective effort, and we believe that every contribution adds value and creativity to our community.
How You Can Contribute:
🛠️ Found a bug? Have an idea for improvement? Fork the repo and create a pull request.
💡 Have a suggestion for making this project even better? Open an issue with the "enhancement" tag.
⭐ Like what you see? Show your support by giving our project a star!
Remember, your contributions, whether big or small, are incredibly valuable to us. They help us learn, inspire, and create a better project together.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Thank you for being a part of this journey!
Dhruv Pamneja - dpamneja@gmail.com / 21f1001719@ds.study.iitm.ac.in
Project Link: https://github.com/d-pamneja/Source_Code_Analysis_Application