File size: 13,414 Bytes
d5fd24d
 
 
 
 
85635d0
d5fd24d
85635d0
d5fd24d
 
85635d0
d5fd24d
85635d0
 
 
 
d5fd24d
85635d0
 
d5fd24d
85635d0
 
 
 
 
 
 
d5fd24d
85635d0
 
 
 
 
 
 
 
 
 
d5fd24d
85635d0
 
 
 
 
 
d5fd24d
 
 
85635d0
 
d5fd24d
85635d0
 
d5fd24d
 
 
85635d0
 
 
 
d5fd24d
85635d0
d5fd24d
 
 
85635d0
 
 
 
 
 
 
d5fd24d
 
85635d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d5fd24d
 
 
85635d0
 
 
 
d5fd24d
 
85635d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d5fd24d
85635d0
 
d5fd24d
 
85635d0
d5fd24d
85635d0
 
 
 
 
 
 
 
 
d5fd24d
85635d0
 
 
 
 
d5fd24d
85635d0
 
 
d5fd24d
85635d0
 
 
 
 
 
 
 
d5fd24d
 
85635d0
 
 
d5fd24d
85635d0
 
 
 
d5fd24d
85635d0
 
d5fd24d
85635d0
d5fd24d
85635d0
 
d5fd24d
85635d0
d5fd24d
 
 
 
 
85635d0
 
 
 
 
d5fd24d
85635d0
 
 
 
 
 
 
 
d5fd24d
85635d0
 
 
 
d5fd24d
 
85635d0
d5fd24d
85635d0
 
 
 
 
 
 
d5fd24d
 
 
 
85635d0
 
d5fd24d
85635d0
 
d5fd24d
 
 
85635d0
d5fd24d
85635d0
 
 
 
 
 
 
 
d5fd24d
85635d0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
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("""
<style>
    .main {background-color: #f8f9fa;}
    .stButton button {
        border-radius: 6px;
        padding: 2px 5px;
        font-size: 0.8em;
        display: inline-flex;
        align-items: center;
        margin: 1px;
        min-height: 0px;
    }
    .stButton button:hover {background-color: #e9ecef;}
    div[data-testid="stVerticalBlock"] {gap: 0.5rem;}
    div[data-testid="stHorizontalBlock"] {gap: 0.5rem;}
    .stTextArea textarea, .stTextInput input {
        padding: 0.3rem;
        font-size: 0.8em;
        min-height: 0px;
    }
    div[data-testid="stForm"] {border-width: 0px; padding: 0rem 0rem;}
    .row-widget.stRadio > div {flex-direction: row;}
    .row-widget.stRadio > div > label {margin: 0px 0.2rem; padding: 0.2rem 0.5rem; font-size: 0.8em;}
    h1, h2, h3 {margin-top: 0; margin-bottom: 0.2rem;}
    h3 {font-size: 1.1rem;}
    p, div {margin-bottom: 0.2rem;}
    .grid-container {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
    }
    .grid-item {margin: 0px;}
    .section-header {
        font-weight: bold;
        font-size: 1rem;
        margin-bottom: 0.2rem;
        margin-top: 0.3rem;
    }
    .prompt-display {
        background-color: #ffffff;
        border-radius: 5px;
        padding: 10px;
        border: 1px solid #e9ecef;
        min-height: 120px;
        font-size: 0.85em;
        white-space: pre-wrap;
    }
    .sample-prompt {
        font-size: 0.8em;
        padding: 5px;
        border-radius: 5px;
        margin-bottom: 5px;
    }
    .emoji {font-size: 1.1em;}
</style>
""", 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"<div class='section-header'>{category_name}</div>", unsafe_allow_html=True)
    st.markdown("<div class='grid-container'>", 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("</div>", unsafe_allow_html=True)

# Header (minimal)
st.markdown("<h2 style='text-align: center;'><span class='emoji'>๐Ÿง </span> ChatGPT Prompt Generator</h2>", 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("<div class='prompt-display'>", unsafe_allow_html=True)
        st.write(prompt)
        st.markdown("</div>", 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("""
        <div style="font-size: 0.75em; background-color: #f1f8ff; border-radius: 5px; padding: 5px; margin-top: 5px;">
        <b>Basic Structure:</b><br>
        Act as [<span style="color:blue">ROLE</span>], use [<span style="color:green">TONE</span>] tone, [<span style="color:red">INSTRUCTION</span>] a [<span style="color:purple">LENGTH</span>] [<span style="color:orange">CONTENT TYPE</span>] for [<span style="color:pink">AUDIENCE</span>].<br>
        It should be about [TOPIC].<br>
        Include [INCLUSION].<br>
        Exclude [EXCLUSION].<br>
        Return as [FORMAT].
        </div>
        """, unsafe_allow_html=True)

with tab2:
    # Display sample prompts in a compact layout
    for prompt in sample_prompts:
        st.markdown(f"""
        <div style="background-color: {prompt['color']}; border: 1px solid {prompt['border']}; border-radius: 5px; padding: 5px; margin-bottom: 5px; font-size: 0.8em;">
            <b>{prompt['title']}</b><pre style="white-space: pre-wrap; font-size: 0.85em; margin: 3px 0px;">{prompt['prompt']}</pre>
        </div>
        """, unsafe_allow_html=True)
    
    # Quick tips
    st.markdown("""
    <div style="background-color: #f8f9fa; border-radius: 5px; padding: 5px; margin-top: 5px; font-size: 0.8em;">
    <b>๐Ÿ“Œ Tips for Effective Prompts:</b>
    <ul style="margin: 0; padding-left: 15px;">
        <li>Be specific about your desired format and style</li>
        <li>Clearly define what to include and exclude</li>
        <li>Specify the target audience for better tailoring</li>
        <li>Use structured prompts for consistent results</li>
    </ul>
    </div>
    """, unsafe_allow_html=True)