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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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: 10px;
|
| 22 |
+
padding: 5px 10px;
|
| 23 |
+
font-weight: 500;
|
| 24 |
+
display: flex;
|
| 25 |
+
align-items: center;
|
| 26 |
+
justify-content: flex-start;
|
| 27 |
+
width: 100%;
|
| 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 |
+
.css-1d391kg {
|
| 49 |
+
padding: 1rem;
|
| 50 |
+
}
|
| 51 |
+
.section-title {
|
| 52 |
+
font-size: 20px;
|
| 53 |
+
font-weight: 600;
|
| 54 |
+
margin-bottom: 10px;
|
| 55 |
+
color: #333;
|
| 56 |
+
}
|
| 57 |
+
.highlight-box {
|
| 58 |
+
background-color: #f1f8ff;
|
| 59 |
+
border-radius: 10px;
|
| 60 |
+
padding: 15px;
|
| 61 |
+
border: 1px solid #c2e0ff;
|
| 62 |
+
}
|
| 63 |
+
.emoji-large {
|
| 64 |
+
font-size: 24px;
|
| 65 |
+
}
|
| 66 |
+
.prompt-display {
|
| 67 |
+
background-color: #ffffff;
|
| 68 |
+
border-radius: 10px;
|
| 69 |
+
padding: 20px;
|
| 70 |
+
border: 1px solid #e9ecef;
|
| 71 |
+
min-height: 200px;
|
| 72 |
+
white-space: pre-wrap;
|
| 73 |
+
}
|
| 74 |
+
.sample-prompt {
|
| 75 |
+
background-color: #f8f9fa;
|
| 76 |
+
border-radius: 10px;
|
| 77 |
+
padding: 15px;
|
| 78 |
+
border: 1px solid #e9ecef;
|
| 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 'selected_role' not in st.session_state:
|
| 97 |
+
st.session_state.selected_role = None
|
| 98 |
+
if 'selected_tone' not in st.session_state:
|
| 99 |
+
st.session_state.selected_tone = None
|
| 100 |
+
if 'selected_instruction' not in st.session_state:
|
| 101 |
+
st.session_state.selected_instruction = None
|
| 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 |
+
roles = [
|
| 121 |
+
{"name": "Professional", "emoji": "๐"},
|
| 122 |
+
{"name": "Expert", "emoji": "๐ง "},
|
| 123 |
+
{"name": "Friend", "emoji": "๐ค"},
|
| 124 |
+
{"name": "Copywriter", "emoji": "โ๏ธ"},
|
| 125 |
+
{"name": "Creative Writer", "emoji": "๐๏ธ"},
|
| 126 |
+
{"name": "Sales Coach", "emoji": "๐ผ"},
|
| 127 |
+
{"name": "Marketing Coach", "emoji": "๐"},
|
| 128 |
+
{"name": "Tech Consultant", "emoji": "๐ป"},
|
| 129 |
+
{"name": "Life Coach", "emoji": "๐ง"},
|
| 130 |
+
{"name": "Data Analyst", "emoji": "๐"},
|
| 131 |
+
{"name": "Influencer", "emoji": "๐ฑ"},
|
| 132 |
+
{"name": "Language Tutor", "emoji": "๐ฃ๏ธ"},
|
| 133 |
+
{"name": "Fitness Trainer", "emoji": "๐ช"},
|
| 134 |
+
{"name": "Teacher", "emoji": "๐จโ๐ซ"},
|
| 135 |
+
{"name": "Therapist", "emoji": "๐ง"},
|
| 136 |
+
{"name": "Detective", "emoji": "๐"}
|
| 137 |
+
]
|
| 138 |
+
|
| 139 |
+
tones = [
|
| 140 |
+
{"name": "Informative", "emoji": "โน๏ธ"},
|
| 141 |
+
{"name": "Inspirational", "emoji": "โจ"},
|
| 142 |
+
{"name": "Humorous", "emoji": "๐"},
|
| 143 |
+
{"name": "Friendly", "emoji": "๐"},
|
| 144 |
+
{"name": "Professional", "emoji": "๐"},
|
| 145 |
+
{"name": "Casual", "emoji": "๐"},
|
| 146 |
+
{"name": "Persuasive", "emoji": "๐ค"},
|
| 147 |
+
{"name": "Encouraging", "emoji": "๐"},
|
| 148 |
+
{"name": "Empathetic", "emoji": "๐ค"},
|
| 149 |
+
{"name": "Serious", "emoji": "๐"},
|
| 150 |
+
{"name": "Enthusiastic", "emoji": "๐คฉ"},
|
| 151 |
+
{"name": "Thoughtful", "emoji": "๐ญ"}
|
| 152 |
+
]
|
| 153 |
+
|
| 154 |
+
instructions = [
|
| 155 |
+
{"name": "Create", "emoji": "๐จ"},
|
| 156 |
+
{"name": "Suggest", "emoji": "๐ก"},
|
| 157 |
+
{"name": "Write", "emoji": "โ๏ธ"},
|
| 158 |
+
{"name": "Compose", "emoji": "๐"},
|
| 159 |
+
{"name": "Analyze", "emoji": "๐"},
|
| 160 |
+
{"name": "Explain", "emoji": "๐"},
|
| 161 |
+
{"name": "Describe", "emoji": "๐"},
|
| 162 |
+
{"name": "Summarize", "emoji": "๐"},
|
| 163 |
+
{"name": "Compare", "emoji": "โ๏ธ"},
|
| 164 |
+
{"name": "Outline", "emoji": "๐"},
|
| 165 |
+
{"name": "Evaluate", "emoji": "โญ"},
|
| 166 |
+
{"name": "List", "emoji": "๐"}
|
| 167 |
+
]
|
| 168 |
+
|
| 169 |
+
lengths = [
|
| 170 |
+
{"name": "300 Words", "emoji": "๐"},
|
| 171 |
+
{"name": "500 Words", "emoji": "๐"},
|
| 172 |
+
{"name": "1000 Words", "emoji": "๐"},
|
| 173 |
+
{"name": "5 Paragraphs", "emoji": "๐"},
|
| 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 |
+
"title": "๐จโ๐ซ Teaching Example",
|
| 233 |
+
"color": "#e6f3ff",
|
| 234 |
+
"border": "#b8daff",
|
| 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 |
+
# Header
|
| 282 |
+
st.markdown("<h1 style='text-align: center; color: #1e3a8a;'><span class='emoji-large'>๐ง </span> ChatGPT Prompt Generator</h1>", unsafe_allow_html=True)
|
| 283 |
+
st.markdown("<p style='text-align: center; margin-bottom: 30px;'>Based on Gyula Rabai's ChatGPT Cheat Sheet</p>", unsafe_allow_html=True)
|
| 284 |
+
|
| 285 |
+
# Main layout
|
| 286 |
+
tab1, tab2, tab3 = st.tabs(["๐ฎ Generate Prompt", "๐ Examples", "โน๏ธ About"])
|
| 287 |
+
|
| 288 |
+
with tab1:
|
| 289 |
+
col1, col2 = st.columns([5, 3])
|
| 290 |
+
|
| 291 |
+
with col1:
|
| 292 |
+
st.markdown("<p class='section-title'>โ๏ธ Select Prompt Components</p>", unsafe_allow_html=True)
|
| 293 |
+
|
| 294 |
+
# Create columns for categories
|
| 295 |
+
row1_col1, row1_col2 = st.columns(2)
|
| 296 |
+
|
| 297 |
+
with row1_col1:
|
| 298 |
+
st.markdown("### ๐ค Choose a Role")
|
| 299 |
+
st.markdown("<div class='category-container'>", unsafe_allow_html=True)
|
| 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 |
+
with row1_col2:
|
| 313 |
+
st.markdown("### ๐ญ Select a Tone")
|
| 314 |
+
st.markdown("<div class='category-container'>", unsafe_allow_html=True)
|
| 315 |
+
st.markdown("<div class='button-container'>", unsafe_allow_html=True)
|
| 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 row2_col2:
|
| 345 |
+
st.markdown("### ๐ Select Length")
|
| 346 |
+
st.markdown("<div class='category-container'>", unsafe_allow_html=True)
|
| 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 col2:
|
| 432 |
+
st.markdown("<p class='section-title'>๐ฎ Generated Prompt</p>", unsafe_allow_html=True)
|
| 433 |
+
|
| 434 |
+
# Generate the prompt based on selections
|
| 435 |
+
prompt = ""
|
| 436 |
+
if (st.session_state.selected_role and st.session_state.selected_tone and
|
| 437 |
+
st.session_state.selected_instruction and st.session_state.selected_length and
|
| 438 |
+
st.session_state.selected_content_type and st.session_state.selected_audience and
|
| 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 {st.session_state.about}."""
|
| 444 |
+
|
| 445 |
+
if st.session_state.inclusion:
|
| 446 |
+
prompt += f"\nInclude {st.session_state.inclusion}."
|
| 447 |
+
|
| 448 |
+
if st.session_state.exclusion:
|
| 449 |
+
prompt += f"\nExclude {st.session_state.exclusion}."
|
| 450 |
+
|
| 451 |
+
prompt += f"\n\nReturn the output as {st.session_state.selected_format['emoji']} {st.session_state.selected_format['name']}."
|
| 452 |
+
|
| 453 |
+
if st.session_state.input_data:
|
| 454 |
+
prompt += f"\nUse the following information: {st.session_state.input_data}"
|
| 455 |
+
else:
|
| 456 |
+
prompt = "Please select all required options and provide a topic to generate a 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 |
+
if prompt != "Please select all required options and provide a topic to generate a prompt.":
|
| 463 |
+
# Copy button
|
| 464 |
+
if st.button("๐ Copy Prompt", type="primary", use_container_width=True):
|
| 465 |
+
st.toast("Prompt copied to clipboard! ๐", icon="โ
")
|
| 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 |
+
# Random prompt generator
|
| 483 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 484 |
+
st.markdown("<p class='section-title'>๐ฒ Need inspiration?</p>", unsafe_allow_html=True)
|
| 485 |
+
|
| 486 |
+
if st.button("๐ฒ Generate Random Prompt", type="secondary", use_container_width=True):
|
| 487 |
+
st.session_state.selected_role = random.choice(roles)
|
| 488 |
+
st.session_state.selected_tone = random.choice(tones)
|
| 489 |
+
st.session_state.selected_instruction = random.choice(instructions)
|
| 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 |
+
# Prompt structure guide
|
| 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 class="highlight-box">
|
| 502 |
+
<p><strong>Basic Structure:</strong></p>
|
| 503 |
+
<p>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;">TARGET AUDIENCE</span>].</p>
|
| 504 |
+
<p>It should be about [<span style="color: gray;">TOPIC</span>].</p>
|
| 505 |
+
<p>Include [<span style="color: green;">INCLUSION</span>].</p>
|
| 506 |
+
<p>Exclude [<span style="color: red;">EXCLUSION</span>].</p>
|
| 507 |
+
<p>Return the output as [<span style="color: blue;">FORMAT</span>].</p>
|
| 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 |
+
st.markdown("<p class='section-title'>๐ Sample Prompts</p>", unsafe_allow_html=True)
|
| 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: {sample_prompts[2]['color']}; border: 1px solid {sample_prompts[2]['border']}; border-radius: 10px; padding: 15px;">
|
| 530 |
+
<h3>{sample_prompts[2]['title']}</h3>
|
| 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 |
+
with col2:
|
| 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 class="highlight-box">
|
| 557 |
+
<h3>๐ง Gyula Rabai's ChatGPT Cheat Sheet</h3>
|
| 558 |
+
<p>This app is based on Gyula Rabai's excellent ChatGPT Cheat Sheet, which provides a structured approach to creating effective prompts for ChatGPT.</p>
|
| 559 |
+
|
| 560 |
+
<h4>How to Use This App:</h4>
|
| 561 |
+
<ol>
|
| 562 |
+
<li>Select components from each category (Role, Tone, Instruction, etc.)</li>
|
| 563 |
+
<li>Fill in the required fields (Topic, Include, Exclude, etc.)</li>
|
| 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 |
+
})
|