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 horizontal button rows 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": "💾"} ] } # Function to create a row of buttons for a category def create_horizontal_button_row(category_name, items, emoji_prefix=""): st.markdown(f'
', unsafe_allow_html=True) st.markdown(f'
{emoji_prefix} {category_name}:
', unsafe_allow_html=True) st.markdown('
', unsafe_allow_html=True) # Create buttons in streamlit (can't be created inside HTML) 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): st.session_state.selections[category_name.lower().replace(' ', '_')] = item st.experimental_rerun() st.markdown('
', unsafe_allow_html=True) # Minimal header st.markdown("

🧠 ChatGPT Prompt Generator

", unsafe_allow_html=True) # Main layout with two columns left_col, right_col = st.columns([3, 1]) with left_col: # Create a horizontal row of buttons for each category create_horizontal_button_row("Role", data['roles'], "👤") create_horizontal_button_row("Tone", data['tones'], "🎭") create_horizontal_button_row("Instruction", data['instructions'], "📝") create_horizontal_button_row("Length", data['lengths'], "📏") create_horizontal_button_row("Content Type", data['content_types'], "📄") create_horizontal_button_row("Audience", data['audiences'], "đŸ‘Ĩ") create_horizontal_button_row("Format", data['formats'], "📋") # Add text inputs in a row container st.markdown('
', unsafe_allow_html=True) st.markdown('
📌 Details:
', unsafe_allow_html=True) # Topic input st.session_state.selections['about'] = st.text_input("Topic", value=st.session_state.selections['about'], placeholder="Enter what the content should be about", label_visibility="collapsed") # Two fields in one row col1, col2 = st.columns(2) with col1: 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") # Input data st.session_state.selections['input_data'] = st.text_area("Input Data", value=st.session_state.selections['input_data'], placeholder="Enter any specific information to use", label_visibility="collapsed", height=60) st.markdown('
', unsafe_allow_html=True) 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." # Display the generated prompt st.markdown('
', unsafe_allow_html=True) st.markdown('
🔮 Generated Prompt:
', unsafe_allow_html=True) st.markdown('
', unsafe_allow_html=True) st.write(prompt) st.markdown('
', unsafe_allow_html=True) # Action buttons in a row col1, col2, col3 = st.columns(3) with col1: if st.button("📋 Copy", type="primary", use_container_width=True): st.code(prompt, language="") 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() with col3: if st.button("🎲 Random", 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() st.markdown('
', unsafe_allow_html=True) # Sample prompts and structure guide st.markdown('
', unsafe_allow_html=True) st.markdown('
📚 Examples:
', unsafe_allow_html=True) st.markdown("""
👨‍đŸĢ Teaching
Act as a 👨‍đŸĢ Teacher, use 📚 Informative tone, Create a 📋 Guide for 🌱 Beginners.

It should be about Git.
Include practical examples.
Exclude advanced techniques.

Return as 📝 Markdown.
đŸ’ŧ Business
Act as a 👔 Professional, use 🤝 Persuasive tone, Write a 📧 Email for 👩‍đŸ’ŧ Executives.

It should be about a product launch.
Include ROI metrics.
Exclude technical details.

Return as 📄 Plain Text.
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) st.markdown('
', unsafe_allow_html=True)