Upload 3 files
Browse filesThis project is an interactive web application built using Gradio and Google Gemini API that demonstrates the impact of different prompt engineering techniques on large language model outputs.
Users can enter any task (e.g., explaining a concept, summarizing text, or answering a question) and compare responses generated using:
1. Zero-Shot Prompting
2. Few-Shot Prompting
3. Chain-of-Thought Prompting
The dashboard helps visualize how prompt design influences the quality, structure, and depth of AI-generated responses.
- README.md +35 -14
- app.py +86 -0
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -1,14 +1,35 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Prompt Engineering Dashboard
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: AI Prompt Engineering Dashboard
|
| 3 |
+
emoji: 🔁
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 4.0
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# AI Prompt Engineering Dashboard
|
| 13 |
+
|
| 14 |
+
This project demonstrates how different prompt engineering techniques affect Large Language Model outputs.
|
| 15 |
+
|
| 16 |
+
## Features
|
| 17 |
+
- Zero-shot prompting
|
| 18 |
+
- Few-shot prompting
|
| 19 |
+
- Chain-of-thought prompting
|
| 20 |
+
- Side-by-side comparison of outputs
|
| 21 |
+
|
| 22 |
+
## What it shows
|
| 23 |
+
- How prompt design affects AI responses
|
| 24 |
+
- LLM behavior under different instructions
|
| 25 |
+
- Practical prompt engineering experimentation
|
| 26 |
+
|
| 27 |
+
## Tech Stack
|
| 28 |
+
- Python
|
| 29 |
+
- Gradio
|
| 30 |
+
- Google Gemini API
|
| 31 |
+
|
| 32 |
+
## Setup
|
| 33 |
+
Add your API key in Hugging Face Spaces:
|
| 34 |
+
|
| 35 |
+
**Settings → Secrets**
|
app.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from google import genai
|
| 3 |
+
|
| 4 |
+
client = genai.Client(api_key="AIzaSyDVVUD7hHXKBRKYVRRQMV6-GMqyRAlOrmo")
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
# AI CALL
|
| 8 |
+
def ask(prompt):
|
| 9 |
+
try:
|
| 10 |
+
response = client.models.generate_content(
|
| 11 |
+
model="gemini-2.5-flash",
|
| 12 |
+
contents=prompt
|
| 13 |
+
)
|
| 14 |
+
return response.text
|
| 15 |
+
except Exception as e:
|
| 16 |
+
return f"Error: {str(e)}"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# PROMPTS
|
| 20 |
+
def zero_shot(task):
|
| 21 |
+
return task
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def few_shot(task):
|
| 25 |
+
return f"""
|
| 26 |
+
Example:
|
| 27 |
+
Q: What is AI?
|
| 28 |
+
A: AI is the simulation of human intelligence in machines.
|
| 29 |
+
|
| 30 |
+
Now answer:
|
| 31 |
+
Q: {task}
|
| 32 |
+
A:
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def cot(task):
|
| 37 |
+
return f"""
|
| 38 |
+
Solve step by step:
|
| 39 |
+
|
| 40 |
+
Task: {task}
|
| 41 |
+
|
| 42 |
+
Step 1:
|
| 43 |
+
Step 2:
|
| 44 |
+
Final Answer:
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
#MAIN FUNCTION
|
| 49 |
+
def run_dashboard(task):
|
| 50 |
+
|
| 51 |
+
z = ask(zero_shot(task))
|
| 52 |
+
f = ask(few_shot(task))
|
| 53 |
+
c = ask(cot(task))
|
| 54 |
+
|
| 55 |
+
return z, f, c
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
# GRADIO UI
|
| 59 |
+
demo = gr.Interface(
|
| 60 |
+
fn=run_dashboard,
|
| 61 |
+
|
| 62 |
+
inputs=gr.Textbox(
|
| 63 |
+
label="✨ Enter Your Prompt",
|
| 64 |
+
placeholder="Example: Explain machine learning in simple terms",
|
| 65 |
+
lines=3
|
| 66 |
+
),
|
| 67 |
+
|
| 68 |
+
outputs=[
|
| 69 |
+
gr.Textbox(label="🔷 Zero-Shot Response"),
|
| 70 |
+
gr.Textbox(label="🟣 Few-Shot Response"),
|
| 71 |
+
gr.Textbox(label="🟢 Chain-of-Thought Response"),
|
| 72 |
+
],
|
| 73 |
+
|
| 74 |
+
title="Prompt Engineering Explorer",
|
| 75 |
+
description="Compare how different prompting styles (Zero-shot, Few-shot, Chain-of-Thought) affect AI-generated responses.",
|
| 76 |
+
|
| 77 |
+
theme=gr.themes.Soft(
|
| 78 |
+
primary_hue="cyan",
|
| 79 |
+
secondary_hue="emerald",
|
| 80 |
+
neutral_hue="slate"
|
| 81 |
+
),
|
| 82 |
+
|
| 83 |
+
allow_flagging="never"
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
google-genai
|