A Python script that generates an experiment document based on the provided experiment number and aim. This tool automates the documentation process, making it easier for students to create structured experiment reports.
- Generate a detailed theory section using the Gemini API.
- Convert HTML content to a formatted Word document.
- Include user-specific details such as name, roll number, and batch.
Before running the script, ensure you have the following:
- Python 3.x installed on your machine.
- A valid API key for the Gemini API.
- Go to Google AI Studio.
- Sign up for a free account if you don't have one.
- Create a new API key and copy it.
- Open the script in your preferred text editor.
- Locate the line with
genai.configure(api_key="")
. - Replace the empty string with your actual API key, like so:
genai.configure(api_key="YOUR_API_KEY_HERE")
To ensure the script runs smoothly, you need to install the required Python packages. You can do this using pip:
pip install google-generativeai python-docx beautifulsoup4
After you have configured the API key and installed the necessary packages, run the script using Python:
python generate_pdf.py
- When prompted, enter the following:
- Experiment Number
- Aim of the Experiment
- Your Name
- Your Roll Number
- Your Batch
After running the script, you will find a Word document named experiment_<experiment_number>_aim_and_theory.docx
in the same directory. This document contains the generated content based on your inputs.
Enter the Experiment Number: 1
Enter the Aim: To study the properties of semiconductors.
Enter your Name: John Doe
Enter your Roll Number: 123456
Enter your Batch: 2024
This project is licensed under the MIT License.
- Google Generative AI for providing the API to generate content.
- Python-docx for handling Word document creation.