Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,601 +1,270 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
from streamlit_option_menu import option_menu
|
4 |
import random
|
5 |
|
6 |
# Set page configuration
|
7 |
-
st.set_page_config(
|
8 |
-
page_title="ChatGPT Prompt Generator",
|
9 |
-
page_icon="🧠",
|
10 |
-
layout="wide",
|
11 |
-
initial_sidebar_state="expanded"
|
12 |
-
)
|
13 |
|
14 |
-
# Custom CSS
|
15 |
st.markdown("""
|
16 |
<style>
|
17 |
-
.main {
|
18 |
-
background-color: #f8f9fa;
|
19 |
-
}
|
20 |
.stButton button {
|
21 |
-
border-radius:
|
22 |
-
padding: 5px
|
23 |
-
font-
|
24 |
-
display: flex;
|
25 |
align-items: center;
|
26 |
-
|
27 |
-
|
28 |
-
text-align: left;
|
29 |
-
}
|
30 |
-
.stButton button:hover {
|
31 |
-
background-color: #e9ecef;
|
32 |
-
}
|
33 |
-
.selected-button {
|
34 |
-
background-color: #4e8df5 !important;
|
35 |
-
color: white !important;
|
36 |
-
}
|
37 |
-
.stTextArea textarea {
|
38 |
-
border-radius: 10px;
|
39 |
-
border: 1px solid #ced4da;
|
40 |
-
}
|
41 |
-
.stTextInput input {
|
42 |
-
border-radius: 10px;
|
43 |
-
border: 1px solid #ced4da;
|
44 |
-
}
|
45 |
-
.css-18e3th9 {
|
46 |
-
padding-top: 1rem;
|
47 |
}
|
48 |
-
.
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
-
.
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
.emoji-large {
|
64 |
-
font-size: 24px;
|
65 |
}
|
66 |
.prompt-display {
|
67 |
background-color: #ffffff;
|
68 |
-
border-radius:
|
69 |
-
padding:
|
70 |
border: 1px solid #e9ecef;
|
71 |
-
min-height:
|
|
|
72 |
white-space: pre-wrap;
|
73 |
}
|
74 |
.sample-prompt {
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
margin-bottom: 10px;
|
80 |
-
}
|
81 |
-
.category-container {
|
82 |
-
max-height: 200px;
|
83 |
-
overflow-y: auto;
|
84 |
-
padding-right: 10px;
|
85 |
-
margin-bottom: 20px;
|
86 |
-
}
|
87 |
-
.button-container {
|
88 |
-
display: flex;
|
89 |
-
flex-wrap: wrap;
|
90 |
-
gap: 5px;
|
91 |
}
|
|
|
92 |
</style>
|
93 |
""", unsafe_allow_html=True)
|
94 |
|
95 |
-
# Initialize session state
|
96 |
-
if '
|
97 |
-
st.session_state.
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
if 'selected_length' not in st.session_state:
|
103 |
-
st.session_state.selected_length = None
|
104 |
-
if 'selected_content_type' not in st.session_state:
|
105 |
-
st.session_state.selected_content_type = None
|
106 |
-
if 'selected_audience' not in st.session_state:
|
107 |
-
st.session_state.selected_audience = None
|
108 |
-
if 'selected_format' not in st.session_state:
|
109 |
-
st.session_state.selected_format = None
|
110 |
-
if 'about' not in st.session_state:
|
111 |
-
st.session_state.about = ""
|
112 |
-
if 'inclusion' not in st.session_state:
|
113 |
-
st.session_state.inclusion = ""
|
114 |
-
if 'exclusion' not in st.session_state:
|
115 |
-
st.session_state.exclusion = ""
|
116 |
-
if 'input_data' not in st.session_state:
|
117 |
-
st.session_state.input_data = ""
|
118 |
|
119 |
# Data sets
|
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 |
-
{"name": "10 Lines", "emoji": "📏"},
|
175 |
-
{"name": "Short", "emoji": "🩳"},
|
176 |
-
{"name": "Medium", "emoji": "📊"},
|
177 |
-
{"name": "Long", "emoji": "📜"},
|
178 |
-
{"name": "Brief", "emoji": "💨"},
|
179 |
-
{"name": "Detailed", "emoji": "🔎"},
|
180 |
-
{"name": "Comprehensive", "emoji": "📚"},
|
181 |
-
{"name": "Concise", "emoji": "✂️"}
|
182 |
-
]
|
183 |
-
|
184 |
-
content_types = [
|
185 |
-
{"name": "Article", "emoji": "📰"},
|
186 |
-
{"name": "Blog post", "emoji": "📝"},
|
187 |
-
{"name": "Guide", "emoji": "📚"},
|
188 |
-
{"name": "Email", "emoji": "📧"},
|
189 |
-
{"name": "Summary", "emoji": "📋"},
|
190 |
-
{"name": "Story", "emoji": "📖"},
|
191 |
-
{"name": "Essay", "emoji": "📄"},
|
192 |
-
{"name": "Review", "emoji": "⭐"},
|
193 |
-
{"name": "Tutorial", "emoji": "👨🏫"},
|
194 |
-
{"name": "Report", "emoji": "📊"},
|
195 |
-
{"name": "Plan", "emoji": "📆"},
|
196 |
-
{"name": "Script", "emoji": "🎬"}
|
197 |
-
]
|
198 |
-
|
199 |
-
audiences = [
|
200 |
-
{"name": "Beginners", "emoji": "🌱"},
|
201 |
-
{"name": "Experts", "emoji": "🧠"},
|
202 |
-
{"name": "Students", "emoji": "🎓"},
|
203 |
-
{"name": "Professionals", "emoji": "👔"},
|
204 |
-
{"name": "Business Owners", "emoji": "💼"},
|
205 |
-
{"name": "General Public", "emoji": "👥"},
|
206 |
-
{"name": "Developers", "emoji": "💻"},
|
207 |
-
{"name": "Children", "emoji": "👶"},
|
208 |
-
{"name": "Teachers", "emoji": "👩🏫"},
|
209 |
-
{"name": "Executives", "emoji": "👩💼"},
|
210 |
-
{"name": "Researchers", "emoji": "🔬"},
|
211 |
-
{"name": "Gamers", "emoji": "🎮"}
|
212 |
-
]
|
213 |
-
|
214 |
-
formats = [
|
215 |
-
{"name": "Markdown", "emoji": "📝"},
|
216 |
-
{"name": "HTML", "emoji": "🌐"},
|
217 |
-
{"name": "Plain Text", "emoji": "📄"},
|
218 |
-
{"name": "JSON", "emoji": "🔄"},
|
219 |
-
{"name": "PDF", "emoji": "📑"},
|
220 |
-
{"name": "Python Code", "emoji": "🐍"},
|
221 |
-
{"name": "JavaScript", "emoji": "📜"},
|
222 |
-
{"name": "SQL Query", "emoji": "💾"},
|
223 |
-
{"name": "LaTeX", "emoji": "📝"},
|
224 |
-
{"name": "Presentation", "emoji": "📊"},
|
225 |
-
{"name": "SVG", "emoji": "🖼️"},
|
226 |
-
{"name": "CSV", "emoji": "📊"}
|
227 |
-
]
|
228 |
|
229 |
# Sample prompts
|
230 |
sample_prompts = [
|
231 |
-
{
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
"prompt": """Act as a 👨🏫 Teacher, use 📚 Informative tone, Create a 📋 Comprehensive Guide for 🌱 Beginners.
|
236 |
-
|
237 |
-
It should be about Git version control.
|
238 |
-
Include practical examples and best practices.
|
239 |
-
Exclude advanced techniques for now.
|
240 |
-
|
241 |
-
Return the output as 📝 Markdown."""
|
242 |
-
},
|
243 |
-
{
|
244 |
-
"title": "💼 Business Example",
|
245 |
-
"color": "#e6ffed",
|
246 |
-
"border": "#b8e6cc",
|
247 |
-
"prompt": """Act as a 👔 Professional, use 🤝 Persuasive tone, Write a 📧 Email for 👩💼 Executives.
|
248 |
-
|
249 |
-
It should be about a new product launch.
|
250 |
-
Include key benefits and ROI metrics.
|
251 |
-
Exclude technical specifications.
|
252 |
-
|
253 |
-
Return the output as 📄 Plain Text."""
|
254 |
-
},
|
255 |
-
{
|
256 |
-
"title": "💻 Technical Example",
|
257 |
-
"color": "#f2e6ff",
|
258 |
-
"border": "#d9b8ff",
|
259 |
-
"prompt": """Act as a 💻 Tech Consultant, use ℹ️ Informative tone, Explain a 📚 Tutorial for 💻 Developers.
|
260 |
-
|
261 |
-
It should be about React hooks.
|
262 |
-
Include real-world use cases.
|
263 |
-
Exclude class components.
|
264 |
-
|
265 |
-
Return the output as 📜 JavaScript."""
|
266 |
-
},
|
267 |
-
{
|
268 |
-
"title": "📖 Creative Example",
|
269 |
-
"color": "#fff8e6",
|
270 |
-
"border": "#ffe0b8",
|
271 |
-
"prompt": """Act as a 🖋️ Creative Writer, use 😄 Humorous tone, Compose a 📖 Story for 👶 Children.
|
272 |
-
|
273 |
-
It should be about a friendly dragon.
|
274 |
-
Include a moral lesson about friendship.
|
275 |
-
Exclude scary elements.
|
276 |
-
|
277 |
-
Return the output as 📝 Markdown."""
|
278 |
-
}
|
279 |
]
|
280 |
|
281 |
-
#
|
282 |
-
|
283 |
-
st.markdown("<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
-
# Main layout
|
286 |
-
tab1, tab2
|
287 |
|
288 |
with tab1:
|
289 |
-
|
290 |
|
291 |
-
with
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
st.markdown("<div class='button-container'>", unsafe_allow_html=True)
|
301 |
-
|
302 |
-
for i, role in enumerate(roles):
|
303 |
-
role_key = f"role_{i}"
|
304 |
-
if st.button(f"{role['emoji']} {role['name']}", key=role_key,
|
305 |
-
help=f"Select {role['name']} as your role",
|
306 |
-
use_container_width=True,
|
307 |
-
type="secondary" if st.session_state.selected_role != role else "primary"):
|
308 |
-
st.session_state.selected_role = role
|
309 |
-
|
310 |
-
st.markdown("</div></div>", unsafe_allow_html=True)
|
311 |
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
st.
|
316 |
-
|
317 |
-
for i, tone in enumerate(tones):
|
318 |
-
tone_key = f"tone_{i}"
|
319 |
-
if st.button(f"{tone['emoji']} {tone['name']}", key=tone_key,
|
320 |
-
help=f"Select {tone['name']} tone",
|
321 |
-
use_container_width=True,
|
322 |
-
type="secondary" if st.session_state.selected_tone != tone else "primary"):
|
323 |
-
st.session_state.selected_tone = tone
|
324 |
-
|
325 |
-
st.markdown("</div></div>", unsafe_allow_html=True)
|
326 |
-
|
327 |
-
row2_col1, row2_col2 = st.columns(2)
|
328 |
-
|
329 |
-
with row2_col1:
|
330 |
-
st.markdown("### 📝 Select an Instruction")
|
331 |
-
st.markdown("<div class='category-container'>", unsafe_allow_html=True)
|
332 |
-
st.markdown("<div class='button-container'>", unsafe_allow_html=True)
|
333 |
-
|
334 |
-
for i, instruction in enumerate(instructions):
|
335 |
-
instruction_key = f"instruction_{i}"
|
336 |
-
if st.button(f"{instruction['emoji']} {instruction['name']}", key=instruction_key,
|
337 |
-
help=f"Select {instruction['name']} as your instruction",
|
338 |
-
use_container_width=True,
|
339 |
-
type="secondary" if st.session_state.selected_instruction != instruction else "primary"):
|
340 |
-
st.session_state.selected_instruction = instruction
|
341 |
-
|
342 |
-
st.markdown("</div></div>", unsafe_allow_html=True)
|
343 |
|
344 |
-
with
|
345 |
-
st.
|
346 |
-
st.
|
347 |
-
st.markdown("<div class='button-container'>", unsafe_allow_html=True)
|
348 |
-
|
349 |
-
for i, length in enumerate(lengths):
|
350 |
-
length_key = f"length_{i}"
|
351 |
-
if st.button(f"{length['emoji']} {length['name']}", key=length_key,
|
352 |
-
help=f"Select {length['name']} as your length",
|
353 |
-
use_container_width=True,
|
354 |
-
type="secondary" if st.session_state.selected_length != length else "primary"):
|
355 |
-
st.session_state.selected_length = length
|
356 |
-
|
357 |
-
st.markdown("</div></div>", unsafe_allow_html=True)
|
358 |
-
|
359 |
-
row3_col1, row3_col2 = st.columns(2)
|
360 |
-
|
361 |
-
with row3_col1:
|
362 |
-
st.markdown("### 📄 Select Content Type")
|
363 |
-
st.markdown("<div class='category-container'>", unsafe_allow_html=True)
|
364 |
-
st.markdown("<div class='button-container'>", unsafe_allow_html=True)
|
365 |
-
|
366 |
-
for i, content_type in enumerate(content_types):
|
367 |
-
content_type_key = f"content_type_{i}"
|
368 |
-
if st.button(f"{content_type['emoji']} {content_type['name']}", key=content_type_key,
|
369 |
-
help=f"Select {content_type['name']} as your content type",
|
370 |
-
use_container_width=True,
|
371 |
-
type="secondary" if st.session_state.selected_content_type != content_type else "primary"):
|
372 |
-
st.session_state.selected_content_type = content_type
|
373 |
-
|
374 |
-
st.markdown("</div></div>", unsafe_allow_html=True)
|
375 |
-
|
376 |
-
with row3_col2:
|
377 |
-
st.markdown("### 👥 Select Target Audience")
|
378 |
-
st.markdown("<div class='category-container'>", unsafe_allow_html=True)
|
379 |
-
st.markdown("<div class='button-container'>", unsafe_allow_html=True)
|
380 |
-
|
381 |
-
for i, audience in enumerate(audiences):
|
382 |
-
audience_key = f"audience_{i}"
|
383 |
-
if st.button(f"{audience['emoji']} {audience['name']}", key=audience_key,
|
384 |
-
help=f"Select {audience['name']} as your target audience",
|
385 |
-
use_container_width=True,
|
386 |
-
type="secondary" if st.session_state.selected_audience != audience else "primary"):
|
387 |
-
st.session_state.selected_audience = audience
|
388 |
-
|
389 |
-
st.markdown("</div></div>", unsafe_allow_html=True)
|
390 |
-
|
391 |
-
row4_col1, row4_col2 = st.columns(2)
|
392 |
-
|
393 |
-
with row4_col1:
|
394 |
-
st.markdown("### 📋 Select Format")
|
395 |
-
st.markdown("<div class='category-container'>", unsafe_allow_html=True)
|
396 |
-
st.markdown("<div class='button-container'>", unsafe_allow_html=True)
|
397 |
-
|
398 |
-
for i, format_item in enumerate(formats):
|
399 |
-
format_key = f"format_{i}"
|
400 |
-
if st.button(f"{format_item['emoji']} {format_item['name']}", key=format_key,
|
401 |
-
help=f"Select {format_item['name']} as your format",
|
402 |
-
use_container_width=True,
|
403 |
-
type="secondary" if st.session_state.selected_format != format_item else "primary"):
|
404 |
-
st.session_state.selected_format = format_item
|
405 |
-
|
406 |
-
st.markdown("</div></div>", unsafe_allow_html=True)
|
407 |
-
|
408 |
-
with row4_col2:
|
409 |
-
st.markdown("### 📌 Additional Details")
|
410 |
-
|
411 |
-
st.text_input("💬 Topic (About)", key="about_input",
|
412 |
-
placeholder="Enter what the content should be about",
|
413 |
-
value=st.session_state.about,
|
414 |
-
on_change=lambda: setattr(st.session_state, 'about', st.session_state.about_input))
|
415 |
-
|
416 |
-
st.text_input("✅ Include", key="inclusion_input",
|
417 |
-
placeholder="What to include in the content",
|
418 |
-
value=st.session_state.inclusion,
|
419 |
-
on_change=lambda: setattr(st.session_state, 'inclusion', st.session_state.inclusion_input))
|
420 |
-
|
421 |
-
st.text_input("❌ Exclude", key="exclusion_input",
|
422 |
-
placeholder="What to exclude from the content",
|
423 |
-
value=st.session_state.exclusion,
|
424 |
-
on_change=lambda: setattr(st.session_state, 'exclusion', st.session_state.exclusion_input))
|
425 |
-
|
426 |
-
st.text_area("📊 Input Data", key="input_data_input",
|
427 |
-
placeholder="Enter any specific information to use",
|
428 |
-
value=st.session_state.input_data,
|
429 |
-
on_change=lambda: setattr(st.session_state, 'input_data', st.session_state.input_data_input))
|
430 |
|
431 |
-
with
|
432 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
|
434 |
-
# Generate the prompt based on selections
|
435 |
prompt = ""
|
436 |
-
if
|
437 |
-
|
438 |
-
|
439 |
-
st.session_state.selected_format and st.session_state.about):
|
440 |
-
|
441 |
-
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']}.
|
442 |
|
443 |
-
It should be about {
|
444 |
-
|
445 |
-
if
|
446 |
-
prompt += f"\nInclude {
|
447 |
|
448 |
-
if
|
449 |
-
prompt += f"\nExclude {
|
450 |
|
451 |
-
prompt += f"\n\nReturn the output as {
|
452 |
|
453 |
-
if
|
454 |
-
prompt += f"\nUse the following information: {
|
455 |
else:
|
456 |
-
prompt = "
|
457 |
|
458 |
st.markdown("<div class='prompt-display'>", unsafe_allow_html=True)
|
459 |
st.write(prompt)
|
460 |
st.markdown("</div>", unsafe_allow_html=True)
|
461 |
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
# Reset button
|
468 |
-
if st.button("🔄 Reset Fields", type="secondary", use_container_width=True):
|
469 |
-
st.session_state.selected_role = None
|
470 |
-
st.session_state.selected_tone = None
|
471 |
-
st.session_state.selected_instruction = None
|
472 |
-
st.session_state.selected_length = None
|
473 |
-
st.session_state.selected_content_type = None
|
474 |
-
st.session_state.selected_audience = None
|
475 |
-
st.session_state.selected_format = None
|
476 |
-
st.session_state.about = ""
|
477 |
-
st.session_state.inclusion = ""
|
478 |
-
st.session_state.exclusion = ""
|
479 |
-
st.session_state.input_data = ""
|
480 |
-
st.experimental_rerun()
|
481 |
|
482 |
-
|
483 |
-
|
484 |
-
|
|
|
|
|
|
|
|
|
|
|
485 |
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
st.session_state.selected_length = random.choice(lengths)
|
491 |
-
st.session_state.selected_content_type = random.choice(content_types)
|
492 |
-
st.session_state.selected_audience = random.choice(audiences)
|
493 |
-
st.session_state.selected_format = random.choice(formats)
|
494 |
st.experimental_rerun()
|
495 |
|
496 |
-
#
|
497 |
-
st.markdown("<br>", unsafe_allow_html=True)
|
498 |
-
st.markdown("<p class='section-title'>📚 Prompt Structure Guide</p>", unsafe_allow_html=True)
|
499 |
-
|
500 |
st.markdown("""
|
501 |
-
<div
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
<p>Use the following information: [<span style="color: purple;">INPUT DATA</span>]</p>
|
509 |
</div>
|
510 |
""", unsafe_allow_html=True)
|
511 |
|
512 |
with tab2:
|
513 |
-
|
514 |
-
|
515 |
-
# Display sample prompts in a 2x2 grid
|
516 |
-
col1, col2 = st.columns(2)
|
517 |
-
|
518 |
-
with col1:
|
519 |
-
# First sample
|
520 |
-
st.markdown(f"""
|
521 |
-
<div style="background-color: {sample_prompts[0]['color']}; border: 1px solid {sample_prompts[0]['border']}; border-radius: 10px; padding: 15px; margin-bottom: 20px;">
|
522 |
-
<h3>{sample_prompts[0]['title']}</h3>
|
523 |
-
<pre style="white-space: pre-wrap; font-family: 'Courier New', monospace; font-size: 14px;">{sample_prompts[0]['prompt']}</pre>
|
524 |
-
</div>
|
525 |
-
""", unsafe_allow_html=True)
|
526 |
-
|
527 |
-
# Third sample
|
528 |
st.markdown(f"""
|
529 |
-
<div style="background-color: {
|
530 |
-
<
|
531 |
-
<pre style="white-space: pre-wrap; font-family: 'Courier New', monospace; font-size: 14px;">{sample_prompts[2]['prompt']}</pre>
|
532 |
</div>
|
533 |
""", unsafe_allow_html=True)
|
534 |
|
535 |
-
|
536 |
-
# Second sample
|
537 |
-
st.markdown(f"""
|
538 |
-
<div style="background-color: {sample_prompts[1]['color']}; border: 1px solid {sample_prompts[1]['border']}; border-radius: 10px; padding: 15px; margin-bottom: 20px;">
|
539 |
-
<h3>{sample_prompts[1]['title']}</h3>
|
540 |
-
<pre style="white-space: pre-wrap; font-family: 'Courier New', monospace; font-size: 14px;">{sample_prompts[1]['prompt']}</pre>
|
541 |
-
</div>
|
542 |
-
""", unsafe_allow_html=True)
|
543 |
-
|
544 |
-
# Fourth sample
|
545 |
-
st.markdown(f"""
|
546 |
-
<div style="background-color: {sample_prompts[3]['color']}; border: 1px solid {sample_prompts[3]['border']}; border-radius: 10px; padding: 15px;">
|
547 |
-
<h3>{sample_prompts[3]['title']}</h3>
|
548 |
-
<pre style="white-space: pre-wrap; font-family: 'Courier New', monospace; font-size: 14px;">{sample_prompts[3]['prompt']}</pre>
|
549 |
-
</div>
|
550 |
-
""", unsafe_allow_html=True)
|
551 |
-
|
552 |
-
with tab3:
|
553 |
-
st.markdown("<p class='section-title'>ℹ️ About This App</p>", unsafe_allow_html=True)
|
554 |
-
|
555 |
st.markdown("""
|
556 |
-
<div
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
<
|
561 |
-
<
|
562 |
-
|
563 |
-
|
564 |
-
<li>View your generated prompt in real-time</li>
|
565 |
-
<li>Copy the prompt to use with ChatGPT</li>
|
566 |
-
</ol>
|
567 |
-
|
568 |
-
<h4>Benefits of Structured Prompts:</h4>
|
569 |
-
<ul>
|
570 |
-
<li>More precise and relevant responses</li>
|
571 |
-
<li>Better control over the AI's output format and style</li>
|
572 |
-
<li>Consistent results across different queries</li>
|
573 |
-
<li>Time-saving by reducing back-and-forth with the AI</li>
|
574 |
-
</ul>
|
575 |
-
|
576 |
-
<p>Original cheat sheet created by Gyula Rabai. More resources at <a href="https://szakai-server.com" target="_blank">szakai-server.com</a></p>
|
577 |
</div>
|
578 |
-
""", unsafe_allow_html=True)
|
579 |
-
|
580 |
-
st.markdown("<br>", unsafe_allow_html=True)
|
581 |
-
st.markdown("<p class='section-title'>📈 Prompt Components Statistics</p>", unsafe_allow_html=True)
|
582 |
-
|
583 |
-
# Generate some stats
|
584 |
-
stats_col1, stats_col2 = st.columns(2)
|
585 |
-
|
586 |
-
with stats_col1:
|
587 |
-
# Create a bar chart for roles distribution
|
588 |
-
roles_df = pd.DataFrame({
|
589 |
-
'Category': [r['name'] for r in roles[:8]],
|
590 |
-
'Count': [random.randint(5, 100) for _ in range(8)]
|
591 |
-
})
|
592 |
-
|
593 |
-
st.subheader("Most Popular Roles")
|
594 |
-
st.bar_chart(roles_df.set_index('Category'))
|
595 |
-
|
596 |
-
with stats_col2:
|
597 |
-
# Create a bar chart for content types distribution
|
598 |
-
content_df = pd.DataFrame({
|
599 |
-
'Category': [c['name'] for c in content_types[:8]],
|
600 |
-
'Count': [random.randint(5, 100) for _ in range(8)]
|
601 |
-
})
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
3 |
import random
|
4 |
|
5 |
# Set page configuration
|
6 |
+
st.set_page_config(page_title="ChatGPT Prompt Generator", page_icon="🧠", layout="wide")
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
# Custom CSS for more compact layout
|
9 |
st.markdown("""
|
10 |
<style>
|
11 |
+
.main {background-color: #f8f9fa;}
|
|
|
|
|
12 |
.stButton button {
|
13 |
+
border-radius: 6px;
|
14 |
+
padding: 2px 5px;
|
15 |
+
font-size: 0.8em;
|
16 |
+
display: inline-flex;
|
17 |
align-items: center;
|
18 |
+
margin: 1px;
|
19 |
+
min-height: 0px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
+
.stButton button:hover {background-color: #e9ecef;}
|
22 |
+
div[data-testid="stVerticalBlock"] {gap: 0.5rem;}
|
23 |
+
div[data-testid="stHorizontalBlock"] {gap: 0.5rem;}
|
24 |
+
.stTextArea textarea, .stTextInput input {
|
25 |
+
padding: 0.3rem;
|
26 |
+
font-size: 0.8em;
|
27 |
+
min-height: 0px;
|
28 |
}
|
29 |
+
div[data-testid="stForm"] {border-width: 0px; padding: 0rem 0rem;}
|
30 |
+
.row-widget.stRadio > div {flex-direction: row;}
|
31 |
+
.row-widget.stRadio > div > label {margin: 0px 0.2rem; padding: 0.2rem 0.5rem; font-size: 0.8em;}
|
32 |
+
h1, h2, h3 {margin-top: 0; margin-bottom: 0.2rem;}
|
33 |
+
h3 {font-size: 1.1rem;}
|
34 |
+
p, div {margin-bottom: 0.2rem;}
|
35 |
+
.grid-container {
|
36 |
+
display: grid;
|
37 |
+
grid-template-columns: repeat(4, 1fr);
|
38 |
+
gap: 2px;
|
39 |
}
|
40 |
+
.grid-item {margin: 0px;}
|
41 |
+
.section-header {
|
42 |
+
font-weight: bold;
|
43 |
+
font-size: 1rem;
|
44 |
+
margin-bottom: 0.2rem;
|
45 |
+
margin-top: 0.3rem;
|
|
|
|
|
46 |
}
|
47 |
.prompt-display {
|
48 |
background-color: #ffffff;
|
49 |
+
border-radius: 5px;
|
50 |
+
padding: 10px;
|
51 |
border: 1px solid #e9ecef;
|
52 |
+
min-height: 120px;
|
53 |
+
font-size: 0.85em;
|
54 |
white-space: pre-wrap;
|
55 |
}
|
56 |
.sample-prompt {
|
57 |
+
font-size: 0.8em;
|
58 |
+
padding: 5px;
|
59 |
+
border-radius: 5px;
|
60 |
+
margin-bottom: 5px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
+
.emoji {font-size: 1.1em;}
|
63 |
</style>
|
64 |
""", unsafe_allow_html=True)
|
65 |
|
66 |
+
# Initialize session state for selections
|
67 |
+
if 'selections' not in st.session_state:
|
68 |
+
st.session_state.selections = {
|
69 |
+
'role': None, 'tone': None, 'instruction': None, 'length': None,
|
70 |
+
'content_type': None, 'audience': None, 'format': None,
|
71 |
+
'about': "", 'inclusion': "", 'exclusion': "", 'input_data': ""
|
72 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
# Data sets
|
75 |
+
data = {
|
76 |
+
'roles': [
|
77 |
+
{"name": "Professional", "emoji": "👔"}, {"name": "Expert", "emoji": "🧠"},
|
78 |
+
{"name": "Friend", "emoji": "🤝"}, {"name": "Copywriter", "emoji": "✍️"},
|
79 |
+
{"name": "Creative Writer", "emoji": "🖋️"}, {"name": "Sales Coach", "emoji": "💼"},
|
80 |
+
{"name": "Marketing Coach", "emoji": "📊"}, {"name": "Tech Consultant", "emoji": "💻"},
|
81 |
+
{"name": "Life Coach", "emoji": "🧘"}, {"name": "Data Analyst", "emoji": "📈"},
|
82 |
+
{"name": "Influencer", "emoji": "📱"}, {"name": "Language Tutor", "emoji": "🗣️"},
|
83 |
+
{"name": "Fitness Trainer", "emoji": "💪"}, {"name": "Teacher", "emoji": "👨🏫"},
|
84 |
+
{"name": "Therapist", "emoji": "🧐"}, {"name": "Detective", "emoji": "🔍"}
|
85 |
+
],
|
86 |
+
'tones': [
|
87 |
+
{"name": "Informative", "emoji": "ℹ️"}, {"name": "Inspirational", "emoji": "✨"},
|
88 |
+
{"name": "Humorous", "emoji": "😄"}, {"name": "Friendly", "emoji": "😊"},
|
89 |
+
{"name": "Professional", "emoji": "👔"}, {"name": "Casual", "emoji": "👋"},
|
90 |
+
{"name": "Persuasive", "emoji": "🤝"}, {"name": "Encouraging", "emoji": "🙌"},
|
91 |
+
{"name": "Empathetic", "emoji": "🤗"}, {"name": "Serious", "emoji": "😐"},
|
92 |
+
{"name": "Enthusiastic", "emoji": "🤩"}, {"name": "Thoughtful", "emoji": "💭"}
|
93 |
+
],
|
94 |
+
'instructions': [
|
95 |
+
{"name": "Create", "emoji": "🔨"}, {"name": "Suggest", "emoji": "💡"},
|
96 |
+
{"name": "Write", "emoji": "✍️"}, {"name": "Compose", "emoji": "📝"},
|
97 |
+
{"name": "Analyze", "emoji": "🔍"}, {"name": "Explain", "emoji": "📚"},
|
98 |
+
{"name": "Describe", "emoji": "🔎"}, {"name": "Summarize", "emoji": "📋"},
|
99 |
+
{"name": "Compare", "emoji": "⚖️"}, {"name": "Outline", "emoji": "📋"},
|
100 |
+
{"name": "Evaluate", "emoji": "⭐"}, {"name": "List", "emoji": "📋"}
|
101 |
+
],
|
102 |
+
'lengths': [
|
103 |
+
{"name": "300 Words", "emoji": "📝"}, {"name": "500 Words", "emoji": "📄"},
|
104 |
+
{"name": "Short", "emoji": "🩳"}, {"name": "Medium", "emoji": "📊"},
|
105 |
+
{"name": "Long", "emoji": "📜"}, {"name": "Brief", "emoji": "💨"},
|
106 |
+
{"name": "Detailed", "emoji": "🔎"}, {"name": "Comprehensive", "emoji": "📚"}
|
107 |
+
],
|
108 |
+
'content_types': [
|
109 |
+
{"name": "Article", "emoji": "📰"}, {"name": "Blog post", "emoji": "📝"},
|
110 |
+
{"name": "Guide", "emoji": "📚"}, {"name": "Email", "emoji": "📧"},
|
111 |
+
{"name": "Summary", "emoji": "📋"}, {"name": "Story", "emoji": "📖"},
|
112 |
+
{"name": "Essay", "emoji": "📄"}, {"name": "Review", "emoji": "⭐"},
|
113 |
+
{"name": "Tutorial", "emoji": "👨🏫"}, {"name": "Report", "emoji": "📊"},
|
114 |
+
{"name": "Plan", "emoji": "📆"}, {"name": "Script", "emoji": "🎬"}
|
115 |
+
],
|
116 |
+
'audiences': [
|
117 |
+
{"name": "Beginners", "emoji": "🌱"}, {"name": "Experts", "emoji": "🧠"},
|
118 |
+
{"name": "Students", "emoji": "🎓"}, {"name": "Professionals", "emoji": "👔"},
|
119 |
+
{"name": "Business Owners", "emoji": "💼"}, {"name": "General Public", "emoji": "👥"},
|
120 |
+
{"name": "Developers", "emoji": "💻"}, {"name": "Children", "emoji": "👶"}
|
121 |
+
],
|
122 |
+
'formats': [
|
123 |
+
{"name": "Markdown", "emoji": "📝"}, {"name": "HTML", "emoji": "🌐"},
|
124 |
+
{"name": "Plain Text", "emoji": "📄"}, {"name": "JSON", "emoji": "🔄"},
|
125 |
+
{"name": "PDF", "emoji": "📑"}, {"name": "Python Code", "emoji": "🐍"},
|
126 |
+
{"name": "JavaScript", "emoji": "📜"}, {"name": "SQL Query", "emoji": "💾"}
|
127 |
+
]
|
128 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
# Sample prompts
|
131 |
sample_prompts = [
|
132 |
+
{"title": "👨🏫 Teaching", "color": "#e6f3ff", "border": "#b8daff",
|
133 |
+
"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."},
|
134 |
+
{"title": "💼 Business", "color": "#e6ffed", "border": "#b8e6cc",
|
135 |
+
"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."}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
]
|
137 |
|
138 |
+
# Function to create buttons for a category
|
139 |
+
def create_category_buttons(category_name, items, col_count=4):
|
140 |
+
st.markdown(f"<div class='section-header'>{category_name}</div>", unsafe_allow_html=True)
|
141 |
+
st.markdown("<div class='grid-container'>", unsafe_allow_html=True)
|
142 |
+
|
143 |
+
for i, item in enumerate(items):
|
144 |
+
key = f"{category_name.lower().replace(' ', '_')}_{i}"
|
145 |
+
is_selected = st.session_state.selections.get(category_name.lower().replace(' ', '_')) == item
|
146 |
+
button_type = "primary" if is_selected else "secondary"
|
147 |
+
|
148 |
+
if st.button(f"{item['emoji']} {item['name']}", key=key, help=f"Select {item['name']}",
|
149 |
+
type=button_type, use_container_width=False):
|
150 |
+
st.session_state.selections[category_name.lower().replace(' ', '_')] = item
|
151 |
+
st.experimental_rerun()
|
152 |
+
|
153 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
154 |
+
|
155 |
+
# Header (minimal)
|
156 |
+
st.markdown("<h2 style='text-align: center;'><span class='emoji'>🧠</span> ChatGPT Prompt Generator</h2>", unsafe_allow_html=True)
|
157 |
|
158 |
+
# Main layout with tabs
|
159 |
+
tab1, tab2 = st.tabs(["🔮 Generator", "📚 Examples"])
|
160 |
|
161 |
with tab1:
|
162 |
+
left_col, right_col = st.columns([7, 3])
|
163 |
|
164 |
+
with left_col:
|
165 |
+
# Compact grid layout for all categories
|
166 |
+
create_category_buttons("Role", data['roles'])
|
167 |
+
create_category_buttons("Tone", data['tones'])
|
168 |
+
create_category_buttons("Instruction", data['instructions'])
|
169 |
+
create_category_buttons("Length", data['lengths'])
|
170 |
+
create_category_buttons("Content Type", data['content_types'])
|
171 |
+
create_category_buttons("Audience", data['audiences'])
|
172 |
+
create_category_buttons("Format", data['formats'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
+
# Text inputs in a more compact layout
|
175 |
+
col1, col2 = st.columns(2)
|
176 |
+
with col1:
|
177 |
+
st.session_state.selections['about'] = st.text_input("💬 Topic", value=st.session_state.selections['about'], placeholder="Enter topic", label_visibility="collapsed")
|
178 |
+
st.session_state.selections['inclusion'] = st.text_input("✅ Include", value=st.session_state.selections['inclusion'], placeholder="What to include", label_visibility="collapsed")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
+
with col2:
|
181 |
+
st.session_state.selections['exclusion'] = st.text_input("❌ Exclude", value=st.session_state.selections['exclusion'], placeholder="What to exclude", label_visibility="collapsed")
|
182 |
+
st.session_state.selections['input_data'] = st.text_input("📊 Data", value=st.session_state.selections['input_data'], placeholder="Input data", label_visibility="collapsed")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
+
with right_col:
|
185 |
+
# Generate prompt based on selections
|
186 |
+
is_complete = all([
|
187 |
+
st.session_state.selections['role'], st.session_state.selections['tone'],
|
188 |
+
st.session_state.selections['instruction'], st.session_state.selections['length'],
|
189 |
+
st.session_state.selections['content_type'], st.session_state.selections['audience'],
|
190 |
+
st.session_state.selections['format'], st.session_state.selections['about']
|
191 |
+
])
|
192 |
|
|
|
193 |
prompt = ""
|
194 |
+
if is_complete:
|
195 |
+
sel = st.session_state.selections
|
196 |
+
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']}.
|
|
|
|
|
|
|
197 |
|
198 |
+
It should be about {sel['about']}."""
|
199 |
+
|
200 |
+
if sel['inclusion']:
|
201 |
+
prompt += f"\nInclude {sel['inclusion']}."
|
202 |
|
203 |
+
if sel['exclusion']:
|
204 |
+
prompt += f"\nExclude {sel['exclusion']}."
|
205 |
|
206 |
+
prompt += f"\n\nReturn the output as {sel['format']['emoji']} {sel['format']['name']}."
|
207 |
|
208 |
+
if sel['input_data']:
|
209 |
+
prompt += f"\nUse the following information: {sel['input_data']}"
|
210 |
else:
|
211 |
+
prompt = "Select all required components and provide a topic."
|
212 |
|
213 |
st.markdown("<div class='prompt-display'>", unsafe_allow_html=True)
|
214 |
st.write(prompt)
|
215 |
st.markdown("</div>", unsafe_allow_html=True)
|
216 |
|
217 |
+
# Action buttons
|
218 |
+
col1, col2 = st.columns(2)
|
219 |
+
with col1:
|
220 |
+
if st.button("📋 Copy", type="primary", use_container_width=True):
|
221 |
+
st.code(prompt) # This is just to show it was copied
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
|
223 |
+
with col2:
|
224 |
+
if st.button("🔄 Reset", type="secondary", use_container_width=True):
|
225 |
+
for key in st.session_state.selections:
|
226 |
+
if key in ['about', 'inclusion', 'exclusion', 'input_data']:
|
227 |
+
st.session_state.selections[key] = ""
|
228 |
+
else:
|
229 |
+
st.session_state.selections[key] = None
|
230 |
+
st.experimental_rerun()
|
231 |
|
232 |
+
# Random generator button
|
233 |
+
if st.button("🎲 Random Prompt", type="secondary", use_container_width=True):
|
234 |
+
for category in ['role', 'tone', 'instruction', 'length', 'content_type', 'audience', 'format']:
|
235 |
+
st.session_state.selections[category] = random.choice(data[category+'s'])
|
|
|
|
|
|
|
|
|
236 |
st.experimental_rerun()
|
237 |
|
238 |
+
# Quick guide
|
|
|
|
|
|
|
239 |
st.markdown("""
|
240 |
+
<div style="font-size: 0.75em; background-color: #f1f8ff; border-radius: 5px; padding: 5px; margin-top: 5px;">
|
241 |
+
<b>Basic Structure:</b><br>
|
242 |
+
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>
|
243 |
+
It should be about [TOPIC].<br>
|
244 |
+
Include [INCLUSION].<br>
|
245 |
+
Exclude [EXCLUSION].<br>
|
246 |
+
Return as [FORMAT].
|
|
|
247 |
</div>
|
248 |
""", unsafe_allow_html=True)
|
249 |
|
250 |
with tab2:
|
251 |
+
# Display sample prompts in a compact layout
|
252 |
+
for prompt in sample_prompts:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
st.markdown(f"""
|
254 |
+
<div style="background-color: {prompt['color']}; border: 1px solid {prompt['border']}; border-radius: 5px; padding: 5px; margin-bottom: 5px; font-size: 0.8em;">
|
255 |
+
<b>{prompt['title']}</b><pre style="white-space: pre-wrap; font-size: 0.85em; margin: 3px 0px;">{prompt['prompt']}</pre>
|
|
|
256 |
</div>
|
257 |
""", unsafe_allow_html=True)
|
258 |
|
259 |
+
# Quick tips
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
st.markdown("""
|
261 |
+
<div style="background-color: #f8f9fa; border-radius: 5px; padding: 5px; margin-top: 5px; font-size: 0.8em;">
|
262 |
+
<b>📌 Tips for Effective Prompts:</b>
|
263 |
+
<ul style="margin: 0; padding-left: 15px;">
|
264 |
+
<li>Be specific about your desired format and style</li>
|
265 |
+
<li>Clearly define what to include and exclude</li>
|
266 |
+
<li>Specify the target audience for better tailoring</li>
|
267 |
+
<li>Use structured prompts for consistent results</li>
|
268 |
+
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
</div>
|
270 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|