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("
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("đŽ 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("đ˛ 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("đ 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]
đ 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]['prompt']}
{sample_prompts[2]['prompt']}
{sample_prompts[1]['prompt']}
{sample_prompts[3]['prompt']}
âšī¸ About This App
", unsafe_allow_html=True) st.markdown("""This app is based on Gyula Rabai's excellent ChatGPT Cheat Sheet, which provides a structured approach to creating effective prompts for ChatGPT.
Original cheat sheet created by Gyula Rabai. More resources at szakai-server.com
đ 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)] })