import streamlit as st import pandas as pd from streamlit_option_menu import option_menu import random # Set page configuration st.set_page_config( page_title="ChatGPT Prompt Generator", page_icon="🧠", layout="wide", initial_sidebar_state="expanded" ) # Custom CSS st.markdown(""" """, unsafe_allow_html=True) # Initialize session state if 'selected_role' not in st.session_state: st.session_state.selected_role = None if 'selected_tone' not in st.session_state: st.session_state.selected_tone = None if 'selected_instruction' not in st.session_state: st.session_state.selected_instruction = None if 'selected_length' not in st.session_state: st.session_state.selected_length = None if 'selected_content_type' not in st.session_state: st.session_state.selected_content_type = None if 'selected_audience' not in st.session_state: st.session_state.selected_audience = None if 'selected_format' not in st.session_state: st.session_state.selected_format = None if 'about' not in st.session_state: st.session_state.about = "" if 'inclusion' not in st.session_state: st.session_state.inclusion = "" if 'exclusion' not in st.session_state: st.session_state.exclusion = "" if 'input_data' not in st.session_state: st.session_state.input_data = "" # Data sets 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": "1000 Words", "emoji": "📃"}, {"name": "5 Paragraphs", "emoji": "📋"}, {"name": "10 Lines", "emoji": "📏"}, {"name": "Short", "emoji": "đŸŠŗ"}, {"name": "Medium", "emoji": "📊"}, {"name": "Long", "emoji": "📜"}, {"name": "Brief", "emoji": "💨"}, {"name": "Detailed", "emoji": "🔎"}, {"name": "Comprehensive", "emoji": "📚"}, {"name": "Concise", "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": "đŸ‘ļ"}, {"name": "Teachers", "emoji": "👩‍đŸĢ"}, {"name": "Executives", "emoji": "👩‍đŸ’ŧ"}, {"name": "Researchers", "emoji": "đŸ”Ŧ"}, {"name": "Gamers", "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": "💾"}, {"name": "LaTeX", "emoji": "📝"}, {"name": "Presentation", "emoji": "📊"}, {"name": "SVG", "emoji": "đŸ–ŧī¸"}, {"name": "CSV", "emoji": "📊"} ] # Sample prompts sample_prompts = [ { "title": "👨‍đŸĢ Teaching Example", "color": "#e6f3ff", "border": "#b8daff", "prompt": """Act as a 👨‍đŸĢ Teacher, use 📚 Informative tone, Create a 📋 Comprehensive Guide for 🌱 Beginners. It should be about Git version control. Include practical examples and best practices. Exclude advanced techniques for now. Return the output as 📝 Markdown.""" }, { "title": "đŸ’ŧ Business Example", "color": "#e6ffed", "border": "#b8e6cc", "prompt": """Act as a 👔 Professional, use 🤝 Persuasive tone, Write a 📧 Email for 👩‍đŸ’ŧ Executives. It should be about a new product launch. Include key benefits and ROI metrics. Exclude technical specifications. Return the output as 📄 Plain Text.""" }, { "title": "đŸ’ģ Technical Example", "color": "#f2e6ff", "border": "#d9b8ff", "prompt": """Act as a đŸ’ģ Tech Consultant, use â„šī¸ Informative tone, Explain a 📚 Tutorial for đŸ’ģ Developers. It should be about React hooks. Include real-world use cases. Exclude class components. Return the output as 📜 JavaScript.""" }, { "title": "📖 Creative Example", "color": "#fff8e6", "border": "#ffe0b8", "prompt": """Act as a đŸ–‹ī¸ Creative Writer, use 😄 Humorous tone, Compose a 📖 Story for đŸ‘ļ Children. It should be about a friendly dragon. Include a moral lesson about friendship. Exclude scary elements. Return the output as 📝 Markdown.""" } ] # Header st.markdown("

🧠 ChatGPT Prompt Generator

", unsafe_allow_html=True) st.markdown("

Based on Gyula Rabai's ChatGPT Cheat Sheet

", unsafe_allow_html=True) # Main layout tab1, tab2, tab3 = st.tabs(["🔮 Generate Prompt", "📚 Examples", "â„šī¸ About"]) with tab1: col1, col2 = st.columns([5, 3]) with col1: st.markdown("

âš™ī¸ Select Prompt Components

", unsafe_allow_html=True) # Create columns for categories row1_col1, row1_col2 = st.columns(2) with row1_col1: st.markdown("### 👤 Choose a Role") st.markdown("
", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) for i, role in enumerate(roles): role_key = f"role_{i}" if st.button(f"{role['emoji']} {role['name']}", key=role_key, help=f"Select {role['name']} as your role", use_container_width=True, type="secondary" if st.session_state.selected_role != role else "primary"): st.session_state.selected_role = role st.markdown("
", unsafe_allow_html=True) with row1_col2: st.markdown("### 🎭 Select a Tone") st.markdown("
", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) for i, tone in enumerate(tones): tone_key = f"tone_{i}" if st.button(f"{tone['emoji']} {tone['name']}", key=tone_key, help=f"Select {tone['name']} tone", use_container_width=True, type="secondary" if st.session_state.selected_tone != tone else "primary"): st.session_state.selected_tone = tone st.markdown("
", unsafe_allow_html=True) row2_col1, row2_col2 = st.columns(2) with row2_col1: st.markdown("### 📝 Select an Instruction") st.markdown("
", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) for i, instruction in enumerate(instructions): instruction_key = f"instruction_{i}" if st.button(f"{instruction['emoji']} {instruction['name']}", key=instruction_key, help=f"Select {instruction['name']} as your instruction", use_container_width=True, type="secondary" if st.session_state.selected_instruction != instruction else "primary"): st.session_state.selected_instruction = instruction st.markdown("
", unsafe_allow_html=True) with row2_col2: st.markdown("### 📏 Select Length") st.markdown("
", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) for i, length in enumerate(lengths): length_key = f"length_{i}" if st.button(f"{length['emoji']} {length['name']}", key=length_key, help=f"Select {length['name']} as your length", use_container_width=True, type="secondary" if st.session_state.selected_length != length else "primary"): st.session_state.selected_length = length st.markdown("
", unsafe_allow_html=True) row3_col1, row3_col2 = st.columns(2) with row3_col1: st.markdown("### 📄 Select Content Type") st.markdown("
", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) for i, content_type in enumerate(content_types): content_type_key = f"content_type_{i}" if st.button(f"{content_type['emoji']} {content_type['name']}", key=content_type_key, help=f"Select {content_type['name']} as your content type", use_container_width=True, type="secondary" if st.session_state.selected_content_type != content_type else "primary"): st.session_state.selected_content_type = content_type st.markdown("
", unsafe_allow_html=True) with row3_col2: st.markdown("### đŸ‘Ĩ Select Target Audience") st.markdown("
", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) for i, audience in enumerate(audiences): audience_key = f"audience_{i}" if st.button(f"{audience['emoji']} {audience['name']}", key=audience_key, help=f"Select {audience['name']} as your target audience", use_container_width=True, type="secondary" if st.session_state.selected_audience != audience else "primary"): st.session_state.selected_audience = audience st.markdown("
", unsafe_allow_html=True) row4_col1, row4_col2 = st.columns(2) with row4_col1: st.markdown("### 📋 Select Format") st.markdown("
", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) for i, format_item in enumerate(formats): format_key = f"format_{i}" if st.button(f"{format_item['emoji']} {format_item['name']}", key=format_key, help=f"Select {format_item['name']} as your format", use_container_width=True, type="secondary" if st.session_state.selected_format != format_item else "primary"): st.session_state.selected_format = format_item st.markdown("
", unsafe_allow_html=True) with row4_col2: st.markdown("### 📌 Additional Details") st.text_input("đŸ’Ŧ Topic (About)", key="about_input", placeholder="Enter what the content should be about", value=st.session_state.about, on_change=lambda: setattr(st.session_state, 'about', st.session_state.about_input)) st.text_input("✅ Include", key="inclusion_input", placeholder="What to include in the content", value=st.session_state.inclusion, on_change=lambda: setattr(st.session_state, 'inclusion', st.session_state.inclusion_input)) st.text_input("❌ Exclude", key="exclusion_input", placeholder="What to exclude from the content", value=st.session_state.exclusion, on_change=lambda: setattr(st.session_state, 'exclusion', st.session_state.exclusion_input)) st.text_area("📊 Input Data", key="input_data_input", placeholder="Enter any specific information to use", value=st.session_state.input_data, on_change=lambda: setattr(st.session_state, 'input_data', st.session_state.input_data_input)) with col2: st.markdown("

🔮 Generated Prompt

", unsafe_allow_html=True) # Generate the prompt based on selections prompt = "" if (st.session_state.selected_role and st.session_state.selected_tone and st.session_state.selected_instruction and st.session_state.selected_length and st.session_state.selected_content_type and st.session_state.selected_audience and st.session_state.selected_format and st.session_state.about): prompt = f"""Act as a {st.session_state.selected_role['emoji']} {st.session_state.selected_role['name']}, use {st.session_state.selected_tone['emoji']} {st.session_state.selected_tone['name']} tone, {st.session_state.selected_instruction['emoji']} {st.session_state.selected_instruction['name']} a {st.session_state.selected_length['emoji']} {st.session_state.selected_length['name']} {st.session_state.selected_content_type['emoji']} {st.session_state.selected_content_type['name']} for {st.session_state.selected_audience['emoji']} {st.session_state.selected_audience['name']}. It should be about {st.session_state.about}.""" if st.session_state.inclusion: prompt += f"\nInclude {st.session_state.inclusion}." if st.session_state.exclusion: prompt += f"\nExclude {st.session_state.exclusion}." prompt += f"\n\nReturn the output as {st.session_state.selected_format['emoji']} {st.session_state.selected_format['name']}." if st.session_state.input_data: prompt += f"\nUse the following information: {st.session_state.input_data}" else: prompt = "Please select all required options and provide a topic to generate a prompt." st.markdown("
", unsafe_allow_html=True) st.write(prompt) st.markdown("
", unsafe_allow_html=True) if prompt != "Please select all required options and provide a topic to generate a prompt.": # Copy button if st.button("📋 Copy Prompt", type="primary", use_container_width=True): st.toast("Prompt copied to clipboard! 🎉", icon="✅") # Reset button if st.button("🔄 Reset Fields", type="secondary", use_container_width=True): st.session_state.selected_role = None st.session_state.selected_tone = None st.session_state.selected_instruction = None st.session_state.selected_length = None st.session_state.selected_content_type = None st.session_state.selected_audience = None st.session_state.selected_format = None st.session_state.about = "" st.session_state.inclusion = "" st.session_state.exclusion = "" st.session_state.input_data = "" st.experimental_rerun() # Random prompt generator st.markdown("
", unsafe_allow_html=True) st.markdown("

🎲 Need inspiration?

", unsafe_allow_html=True) if st.button("🎲 Generate Random Prompt", type="secondary", use_container_width=True): st.session_state.selected_role = random.choice(roles) st.session_state.selected_tone = random.choice(tones) st.session_state.selected_instruction = random.choice(instructions) st.session_state.selected_length = random.choice(lengths) st.session_state.selected_content_type = random.choice(content_types) st.session_state.selected_audience = random.choice(audiences) st.session_state.selected_format = random.choice(formats) st.experimental_rerun() # Prompt structure guide st.markdown("
", unsafe_allow_html=True) st.markdown("

📚 Prompt Structure Guide

", unsafe_allow_html=True) st.markdown("""

Basic Structure:

Act as [ROLE], use [TONE] tone, [INSTRUCTION] a [LENGTH] [CONTENT TYPE] for [TARGET AUDIENCE].

It should be about [TOPIC].

Include [INCLUSION].

Exclude [EXCLUSION].

Return the output as [FORMAT].

Use the following information: [INPUT DATA]

""", unsafe_allow_html=True) with tab2: st.markdown("

📚 Sample Prompts

", unsafe_allow_html=True) # Display sample prompts in a 2x2 grid col1, col2 = st.columns(2) with col1: # First sample st.markdown(f"""

{sample_prompts[0]['title']}

{sample_prompts[0]['prompt']}
""", unsafe_allow_html=True) # Third sample st.markdown(f"""

{sample_prompts[2]['title']}

{sample_prompts[2]['prompt']}
""", unsafe_allow_html=True) with col2: # Second sample st.markdown(f"""

{sample_prompts[1]['title']}

{sample_prompts[1]['prompt']}
""", unsafe_allow_html=True) # Fourth sample st.markdown(f"""

{sample_prompts[3]['title']}

{sample_prompts[3]['prompt']}
""", unsafe_allow_html=True) with tab3: st.markdown("

â„šī¸ About This App

", unsafe_allow_html=True) st.markdown("""

🧠 Gyula Rabai's ChatGPT Cheat Sheet

This app is based on Gyula Rabai's excellent ChatGPT Cheat Sheet, which provides a structured approach to creating effective prompts for ChatGPT.

How to Use This App:

  1. Select components from each category (Role, Tone, Instruction, etc.)
  2. Fill in the required fields (Topic, Include, Exclude, etc.)
  3. View your generated prompt in real-time
  4. Copy the prompt to use with ChatGPT

Benefits of Structured Prompts:

Original cheat sheet created by Gyula Rabai. More resources at szakai-server.com

""", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) st.markdown("

📈 Prompt Components Statistics

", unsafe_allow_html=True) # Generate some stats stats_col1, stats_col2 = st.columns(2) with stats_col1: # Create a bar chart for roles distribution roles_df = pd.DataFrame({ 'Category': [r['name'] for r in roles[:8]], 'Count': [random.randint(5, 100) for _ in range(8)] }) st.subheader("Most Popular Roles") st.bar_chart(roles_df.set_index('Category')) with stats_col2: # Create a bar chart for content types distribution content_df = pd.DataFrame({ 'Category': [c['name'] for c in content_types[:8]], 'Count': [random.randint(5, 100) for _ in range(8)] })