This project is a web-based Python code reviewer application built using Streamlit. It allows users to upload Python code, review it for potential bugs and improvements using the Gemini AI model, and run the code to see its output.
- Code Upload: Upload a Python file to be reviewed and executed.
- Code Editor: Edit the uploaded code directly in the web interface.
- Run Code: Execute the Python code and capture its output.
- Review Code: Send the code to Gemini AI for review and receive feedback.
- Apply Fixed Code: Automatically apply the fixed version of the code suggested by the AI.
│
├── Code-Reviewer.py # Main application script
├── requirements.txt # List of dependencies
├── README.md # Project documentation
├── Output.png # Example output screenshot
└── .env # Environment variables (not included in version control)
-
Clone the repository:
git clone https://github.com/nithish-2003/Innomatics-task02 cd Innomatics-task02 -
Install the required packages:
pip install -r requirements.txt
The
requirements.txtfile contains the following dependencies:streamlit requests google-generativeai streamlit_ace uuid datetime -
Set up environment variables:
- Create a
.envfile in the project directory. - Add your Gemini API key to the
.envfile:GEMINI_API_KEY=your_gemini_api_key
- Create a
To use the Gemini AI model, you need to obtain an API key. Follow these steps:
-
Sign up for an account:
- Visit the Console Cloud website and sign up for an account.
-
Generate an API key:
- After logging in, navigate to the API section of your account.
- Generate a new API key and copy it.
-
Set the API key:
- Add the API key to your
.envfile as shown in the installation steps.
- Add the API key to your
-
Run the Streamlit application:
streamlit run Code-Reviewer.py
-
Upload a Python file:
- Use the file uploader to select a Python file from your local machine.
-
Edit the code:
- Use the integrated code editor to make any changes to the uploaded code.
-
Review and Run the code:
- Click the "Review and Run Code" button to execute the code and get a review from the AI.
-
Apply Fixed Code:
- If the AI suggests any fixes, click the "Apply Fixed Code" button to automatically apply the changes.
Below is an example of the output generated by the application:
streamlitrequestsgoogle-generativeaistreamlit_aceuuiddatetimepython-dotenv
The application requires the following environment variables to be set:
GEMINI_API_KEY: Your Gemini API key for accessing the AI model.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
For any questions or inquiries, please contact [Nithish] at [nsr631607@gmail.com].
