This project is an interactive Prompt Engineering Playground built within a Jupyter Notebook using ipywidgets
. It serves as a powerful tool for experimenting with and comparing responses from different Large Language Models (LLMs).
The main notebook, 04_prompt_engineering_pro.ipynb
, provides a control panel with interactive widgets to dynamically change:
- The AI Model (supporting Google Gemini models like
gemini-1.5-pro
andgemini-1.5-flash
) - Generation Parameters like
temperature
,top_p
,top_k
, andmax_output_tokens
- The
System Prompt
andUser Prompt
It features advanced output formatting, which renders Markdown, highlights code blocks, and adds a "Copy Code" button to each block for an enhanced user experience.
Follow these steps to set up and run the project locally.
- Python 3.8+
- Git
-
Clone the repository:
git clone [https://github.com/devtraldi/project_prompt_engineering.git](https://github.com/devtraldi/project_prompt_engineering.git)
-
Navigate to the project directory:
cd project_prompt_engineering
-
Create and activate a virtual environment:
# Create the venv python -m venv venv # Activate on Windows venv\Scripts\activate
-
Install the required libraries:
pip install -r requirements.txt
-
Set up your API Key in
.env
:- Make a copy of the
.env.example
file and name it.env
. - Open
.env
and add your Google API Key. You can get a free key at aistudio.google.com.
Your
.env
file should look like this:# Required for the main features GOOGLE_API_KEY="AIzaSy..."
- Make a copy of the
- Ensure your virtual environment is active.
- Start JupyterLab from your terminal:
jupyter lab
- In the JupyterLab interface, navigate to the
notebooks
folder and open04_prompt_engineering_pro.ipynb
. - Run all the cells. The interactive control panel will appear.
- Modify the parameters using the widgets and click "Generate Response" to experiment.