import streamlit as st
import pandas as pd
import random
# Set page configuration
st.set_page_config(page_title="ChatGPT Prompt Generator", page_icon="đ§ ", layout="wide")
# Custom CSS for more compact layout
st.markdown("""
""", unsafe_allow_html=True)
# Initialize session state for selections
if 'selections' not in st.session_state:
st.session_state.selections = {
'role': None, 'tone': None, 'instruction': None, 'length': None,
'content_type': None, 'audience': None, 'format': None,
'about': "", 'inclusion': "", 'exclusion': "", 'input_data': ""
}
# Data sets
data = {
'roles': [
{"name": "Professional", "emoji": "đ"}, {"name": "Expert", "emoji": "đ§ "},
{"name": "Friend", "emoji": "đ¤"}, {"name": "Copywriter", "emoji": "âī¸"},
{"name": "Creative Writer", "emoji": "đī¸"}, {"name": "Sales Coach", "emoji": "đŧ"},
{"name": "Marketing Coach", "emoji": "đ"}, {"name": "Tech Consultant", "emoji": "đģ"},
{"name": "Life Coach", "emoji": "đ§"}, {"name": "Data Analyst", "emoji": "đ"},
{"name": "Influencer", "emoji": "đą"}, {"name": "Language Tutor", "emoji": "đŖī¸"},
{"name": "Fitness Trainer", "emoji": "đĒ"}, {"name": "Teacher", "emoji": "đ¨âđĢ"},
{"name": "Therapist", "emoji": "đ§"}, {"name": "Detective", "emoji": "đ"}
],
'tones': [
{"name": "Informative", "emoji": "âšī¸"}, {"name": "Inspirational", "emoji": "â¨"},
{"name": "Humorous", "emoji": "đ"}, {"name": "Friendly", "emoji": "đ"},
{"name": "Professional", "emoji": "đ"}, {"name": "Casual", "emoji": "đ"},
{"name": "Persuasive", "emoji": "đ¤"}, {"name": "Encouraging", "emoji": "đ"},
{"name": "Empathetic", "emoji": "đ¤"}, {"name": "Serious", "emoji": "đ"},
{"name": "Enthusiastic", "emoji": "đ¤Š"}, {"name": "Thoughtful", "emoji": "đ"}
],
'instructions': [
{"name": "Create", "emoji": "đ¨"}, {"name": "Suggest", "emoji": "đĄ"},
{"name": "Write", "emoji": "âī¸"}, {"name": "Compose", "emoji": "đ"},
{"name": "Analyze", "emoji": "đ"}, {"name": "Explain", "emoji": "đ"},
{"name": "Describe", "emoji": "đ"}, {"name": "Summarize", "emoji": "đ"},
{"name": "Compare", "emoji": "âī¸"}, {"name": "Outline", "emoji": "đ"},
{"name": "Evaluate", "emoji": "â"}, {"name": "List", "emoji": "đ"}
],
'lengths': [
{"name": "300 Words", "emoji": "đ"}, {"name": "500 Words", "emoji": "đ"},
{"name": "Short", "emoji": "đŠŗ"}, {"name": "Medium", "emoji": "đ"},
{"name": "Long", "emoji": "đ"}, {"name": "Brief", "emoji": "đ¨"},
{"name": "Detailed", "emoji": "đ"}, {"name": "Comprehensive", "emoji": "đ"}
],
'content_types': [
{"name": "Article", "emoji": "đ°"}, {"name": "Blog post", "emoji": "đ"},
{"name": "Guide", "emoji": "đ"}, {"name": "Email", "emoji": "đ§"},
{"name": "Summary", "emoji": "đ"}, {"name": "Story", "emoji": "đ"},
{"name": "Essay", "emoji": "đ"}, {"name": "Review", "emoji": "â"},
{"name": "Tutorial", "emoji": "đ¨âđĢ"}, {"name": "Report", "emoji": "đ"},
{"name": "Plan", "emoji": "đ"}, {"name": "Script", "emoji": "đŦ"}
],
'audiences': [
{"name": "Beginners", "emoji": "đą"}, {"name": "Experts", "emoji": "đ§ "},
{"name": "Students", "emoji": "đ"}, {"name": "Professionals", "emoji": "đ"},
{"name": "Business Owners", "emoji": "đŧ"}, {"name": "General Public", "emoji": "đĨ"},
{"name": "Developers", "emoji": "đģ"}, {"name": "Children", "emoji": "đļ"}
],
'formats': [
{"name": "Markdown", "emoji": "đ"}, {"name": "HTML", "emoji": "đ"},
{"name": "Plain Text", "emoji": "đ"}, {"name": "JSON", "emoji": "đ"},
{"name": "PDF", "emoji": "đ"}, {"name": "Python Code", "emoji": "đ"},
{"name": "JavaScript", "emoji": "đ"}, {"name": "SQL Query", "emoji": "đž"}
]
}
# Sample prompts
sample_prompts = [
{"title": "đ¨âđĢ Teaching", "color": "#e6f3ff", "border": "#b8daff",
"prompt": "Act as a đ¨âđĢ Teacher, use đ Informative tone, Create a đ Guide for đą Beginners.\n\nIt should be about Git version control.\nInclude practical examples.\nExclude advanced techniques.\n\nReturn as đ Markdown."},
{"title": "đŧ Business", "color": "#e6ffed", "border": "#b8e6cc",
"prompt": "Act as a đ Professional, use đ¤ Persuasive tone, Write a đ§ Email for đŠâđŧ Executives.\n\nIt should be about a product launch.\nInclude ROI metrics.\nExclude technical details.\n\nReturn as đ Plain Text."}
]
# Function to create buttons for a category
def create_category_buttons(category_name, items, col_count=4):
st.markdown(f"
", unsafe_allow_html=True)
st.markdown("", unsafe_allow_html=True)
for i, item in enumerate(items):
key = f"{category_name.lower().replace(' ', '_')}_{i}"
is_selected = st.session_state.selections.get(category_name.lower().replace(' ', '_')) == item
button_type = "primary" if is_selected else "secondary"
if st.button(f"{item['emoji']} {item['name']}", key=key, help=f"Select {item['name']}",
type=button_type, use_container_width=False):
st.session_state.selections[category_name.lower().replace(' ', '_')] = item
st.experimental_rerun()
st.markdown("
", unsafe_allow_html=True)
# Header (minimal)
st.markdown("đ§ ChatGPT Prompt Generator
", unsafe_allow_html=True)
# Main layout with tabs
tab1, tab2 = st.tabs(["đŽ Generator", "đ Examples"])
with tab1:
left_col, right_col = st.columns([7, 3])
with left_col:
# Compact grid layout for all categories
create_category_buttons("Role", data['roles'])
create_category_buttons("Tone", data['tones'])
create_category_buttons("Instruction", data['instructions'])
create_category_buttons("Length", data['lengths'])
create_category_buttons("Content Type", data['content_types'])
create_category_buttons("Audience", data['audiences'])
create_category_buttons("Format", data['formats'])
# Text inputs in a more compact layout
col1, col2 = st.columns(2)
with col1:
st.session_state.selections['about'] = st.text_input("đŦ Topic", value=st.session_state.selections['about'], placeholder="Enter topic", label_visibility="collapsed")
st.session_state.selections['inclusion'] = st.text_input("â
Include", value=st.session_state.selections['inclusion'], placeholder="What to include", label_visibility="collapsed")
with col2:
st.session_state.selections['exclusion'] = st.text_input("â Exclude", value=st.session_state.selections['exclusion'], placeholder="What to exclude", label_visibility="collapsed")
st.session_state.selections['input_data'] = st.text_input("đ Data", value=st.session_state.selections['input_data'], placeholder="Input data", label_visibility="collapsed")
with right_col:
# Generate prompt based on selections
is_complete = all([
st.session_state.selections['role'], st.session_state.selections['tone'],
st.session_state.selections['instruction'], st.session_state.selections['length'],
st.session_state.selections['content_type'], st.session_state.selections['audience'],
st.session_state.selections['format'], st.session_state.selections['about']
])
prompt = ""
if is_complete:
sel = st.session_state.selections
prompt = f"""Act as a {sel['role']['emoji']} {sel['role']['name']}, use {sel['tone']['emoji']} {sel['tone']['name']} tone, {sel['instruction']['emoji']} {sel['instruction']['name']} a {sel['length']['emoji']} {sel['length']['name']} {sel['content_type']['emoji']} {sel['content_type']['name']} for {sel['audience']['emoji']} {sel['audience']['name']}.
It should be about {sel['about']}."""
if sel['inclusion']:
prompt += f"\nInclude {sel['inclusion']}."
if sel['exclusion']:
prompt += f"\nExclude {sel['exclusion']}."
prompt += f"\n\nReturn the output as {sel['format']['emoji']} {sel['format']['name']}."
if sel['input_data']:
prompt += f"\nUse the following information: {sel['input_data']}"
else:
prompt = "Select all required components and provide a topic."
st.markdown("", unsafe_allow_html=True)
st.write(prompt)
st.markdown("
", unsafe_allow_html=True)
# Action buttons
col1, col2 = st.columns(2)
with col1:
if st.button("đ Copy", type="primary", use_container_width=True):
st.code(prompt) # This is just to show it was copied
with col2:
if st.button("đ Reset", type="secondary", use_container_width=True):
for key in st.session_state.selections:
if key in ['about', 'inclusion', 'exclusion', 'input_data']:
st.session_state.selections[key] = ""
else:
st.session_state.selections[key] = None
st.experimental_rerun()
# Random generator button
if st.button("đ˛ Random Prompt", type="secondary", use_container_width=True):
for category in ['role', 'tone', 'instruction', 'length', 'content_type', 'audience', 'format']:
st.session_state.selections[category] = random.choice(data[category+'s'])
st.experimental_rerun()
# Quick guide
st.markdown("""
Basic Structure:
Act as [ROLE], use [TONE] tone, [INSTRUCTION] a [LENGTH] [CONTENT TYPE] for [AUDIENCE].
It should be about [TOPIC].
Include [INCLUSION].
Exclude [EXCLUSION].
Return as [FORMAT].
""", unsafe_allow_html=True)
with tab2:
# Display sample prompts in a compact layout
for prompt in sample_prompts:
st.markdown(f"""
{prompt['title']}{prompt['prompt']}
""", unsafe_allow_html=True)
# Quick tips
st.markdown("""
đ Tips for Effective Prompts:
- Be specific about your desired format and style
- Clearly define what to include and exclude
- Specify the target audience for better tailoring
- Use structured prompts for consistent results
""", unsafe_allow_html=True)