Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,64 +1,76 @@
|
|
| 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
|
| 9 |
st.markdown("""
|
| 10 |
<style>
|
| 11 |
.main {background-color: #f8f9fa;}
|
| 12 |
-
.stButton button {
|
| 13 |
-
border-radius: 4px;
|
| 14 |
-
padding: 2px 4px;
|
| 15 |
-
font-size: 0.75em;
|
| 16 |
-
margin: 1px;
|
| 17 |
-
white-space: nowrap;
|
| 18 |
-
}
|
| 19 |
-
.stButton button:hover {background-color: #e9ecef;}
|
| 20 |
div[data-testid="stVerticalBlock"] {gap: 0.2rem;}
|
| 21 |
div[data-testid="stHorizontalBlock"] {gap: 0.3rem;}
|
| 22 |
.stTextArea textarea, .stTextInput input {
|
| 23 |
-
padding: 0.
|
| 24 |
-
font-size: 0.
|
| 25 |
}
|
| 26 |
-
h1, h2, h3 {margin-top: 0; margin-bottom: 0.
|
| 27 |
-
p, div {margin-bottom: 0.1rem;
|
| 28 |
-
.category-
|
| 29 |
-
background-color: white;
|
| 30 |
-
border: 1px solid #e6e6e6;
|
| 31 |
-
border-radius: 4px;
|
| 32 |
-
padding: 5px;
|
| 33 |
-
margin-bottom: 5px;
|
| 34 |
-
}
|
| 35 |
-
.category-label {
|
| 36 |
font-weight: bold;
|
| 37 |
-
font-size:
|
|
|
|
| 38 |
color: #333;
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
}
|
| 43 |
-
.horizontal-buttons {
|
| 44 |
-
display: flex;
|
| 45 |
-
flex-wrap: wrap;
|
| 46 |
-
gap: 2px;
|
| 47 |
-
align-items: center;
|
| 48 |
}
|
| 49 |
.prompt-display {
|
| 50 |
background-color: #ffffff;
|
| 51 |
border-radius: 4px;
|
| 52 |
-
padding:
|
| 53 |
border: 1px solid #e9ecef;
|
| 54 |
-
min-height:
|
| 55 |
-
font-size: 0.8em;
|
| 56 |
white-space: pre-wrap;
|
| 57 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
</style>
|
| 59 |
""", unsafe_allow_html=True)
|
| 60 |
|
| 61 |
-
# Initialize session state
|
| 62 |
if 'selections' not in st.session_state:
|
| 63 |
st.session_state.selections = {
|
| 64 |
'role': None, 'tone': None, 'instruction': None, 'length': None,
|
|
@@ -66,7 +78,7 @@ if 'selections' not in st.session_state:
|
|
| 66 |
'about': "", 'inclusion': "", 'exclusion': "", 'input_data': ""
|
| 67 |
}
|
| 68 |
|
| 69 |
-
# Data sets
|
| 70 |
data = {
|
| 71 |
'roles': [
|
| 72 |
{"name": "Professional", "emoji": "๐"}, {"name": "Expert", "emoji": "๐ง "},
|
|
@@ -122,118 +134,174 @@ data = {
|
|
| 122 |
]
|
| 123 |
}
|
| 124 |
|
| 125 |
-
# Function to
|
| 126 |
-
def
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
| 130 |
|
| 131 |
-
#
|
| 132 |
for i, item in enumerate(items):
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
-
if
|
| 138 |
-
|
| 139 |
-
type=button_type):
|
| 140 |
-
st.session_state.selections[category_name.lower().replace(' ', '_')] = item
|
| 141 |
-
st.experimental_rerun()
|
| 142 |
|
| 143 |
-
st.markdown(
|
| 144 |
|
| 145 |
-
#
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
# Main layout with two columns
|
| 149 |
-
|
| 150 |
|
| 151 |
-
with
|
| 152 |
-
# Create
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
#
|
| 162 |
-
st.markdown(
|
| 163 |
-
st.markdown(
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
label_visibility="collapsed")
|
| 170 |
-
|
| 171 |
-
# Two fields in one row
|
| 172 |
col1, col2 = st.columns(2)
|
| 173 |
with col1:
|
| 174 |
-
st.session_state.selections['inclusion'] = st.text_input("Include",
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
label_visibility="collapsed")
|
| 178 |
|
| 179 |
with col2:
|
| 180 |
-
st.session_state.selections['exclusion'] = st.text_input("Exclude",
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
height=60)
|
| 191 |
-
|
| 192 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 193 |
-
|
| 194 |
-
with right_col:
|
| 195 |
-
# Generate prompt based on selections
|
| 196 |
-
is_complete = all([
|
| 197 |
-
st.session_state.selections['role'], st.session_state.selections['tone'],
|
| 198 |
-
st.session_state.selections['instruction'], st.session_state.selections['length'],
|
| 199 |
-
st.session_state.selections['content_type'], st.session_state.selections['audience'],
|
| 200 |
-
st.session_state.selections['format'], st.session_state.selections['about']
|
| 201 |
-
])
|
| 202 |
-
|
| 203 |
-
prompt = ""
|
| 204 |
-
if is_complete:
|
| 205 |
-
sel = st.session_state.selections
|
| 206 |
-
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']}.
|
| 207 |
-
|
| 208 |
-
It should be about {sel['about']}."""
|
| 209 |
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
if sel['input_data']:
|
| 219 |
-
prompt += f"\nUse the following information: {sel['input_data']}"
|
| 220 |
-
else:
|
| 221 |
-
prompt = "Select all required components and provide a topic."
|
| 222 |
-
|
| 223 |
-
# Display the generated prompt
|
| 224 |
-
st.markdown('<div class="category-row">', unsafe_allow_html=True)
|
| 225 |
-
st.markdown('<div class="category-label">๐ฎ Generated Prompt:</div>', unsafe_allow_html=True)
|
| 226 |
-
st.markdown('<div class="prompt-display">', unsafe_allow_html=True)
|
| 227 |
st.write(prompt)
|
| 228 |
-
st.markdown(
|
| 229 |
|
| 230 |
-
# Action buttons
|
| 231 |
-
|
| 232 |
-
with
|
| 233 |
if st.button("๐ Copy", type="primary", use_container_width=True):
|
| 234 |
st.code(prompt, language="")
|
| 235 |
|
| 236 |
-
with
|
| 237 |
if st.button("๐ Reset", type="secondary", use_container_width=True):
|
| 238 |
for key in st.session_state.selections:
|
| 239 |
if key in ['about', 'inclusion', 'exclusion', 'input_data']:
|
|
@@ -242,21 +310,22 @@ It should be about {sel['about']}."""
|
|
| 242 |
st.session_state.selections[key] = None
|
| 243 |
st.experimental_rerun()
|
| 244 |
|
| 245 |
-
with
|
| 246 |
if st.button("๐ฒ Random", type="secondary", use_container_width=True):
|
| 247 |
for category in ['role', 'tone', 'instruction', 'length', 'content_type', 'audience', 'format']:
|
| 248 |
st.session_state.selections[category] = random.choice(data[category+'s'])
|
| 249 |
st.experimental_rerun()
|
| 250 |
|
| 251 |
-
st.markdown(
|
| 252 |
|
| 253 |
-
# Sample prompts
|
| 254 |
-
st.markdown(
|
| 255 |
-
st.markdown(
|
| 256 |
|
|
|
|
| 257 |
st.markdown("""
|
| 258 |
-
<div style="background-color: #e6f3ff; border: 1px solid #b8daff; border-radius: 4px; padding:
|
| 259 |
-
<b>๐จโ๐ซ Teaching</b><pre style="white-space: pre-wrap; font-size: 0.
|
| 260 |
|
| 261 |
It should be about Git.
|
| 262 |
Include practical examples.
|
|
@@ -264,9 +333,12 @@ Exclude advanced techniques.
|
|
| 264 |
|
| 265 |
Return as ๐ Markdown.</pre>
|
| 266 |
</div>
|
|
|
|
| 267 |
|
| 268 |
-
|
| 269 |
-
|
|
|
|
|
|
|
| 270 |
|
| 271 |
It should be about a product launch.
|
| 272 |
Include ROI metrics.
|
|
@@ -274,9 +346,12 @@ Exclude technical details.
|
|
| 274 |
|
| 275 |
Return as ๐ Plain Text.</pre>
|
| 276 |
</div>
|
|
|
|
| 277 |
|
| 278 |
-
|
| 279 |
-
|
|
|
|
|
|
|
| 280 |
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>
|
| 281 |
It should be about [TOPIC].<br>
|
| 282 |
Include [INCLUSION]. Exclude [EXCLUSION].<br>
|
|
@@ -284,4 +359,4 @@ Return as ๐ Plain Text.</pre>
|
|
| 284 |
</div>
|
| 285 |
""", unsafe_allow_html=True)
|
| 286 |
|
| 287 |
-
st.markdown(
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import random
|
| 4 |
+
import json
|
| 5 |
|
| 6 |
# Set page configuration
|
| 7 |
st.set_page_config(page_title="ChatGPT Prompt Generator", page_icon="๐ง ", layout="wide")
|
| 8 |
|
| 9 |
+
# Custom CSS for styling
|
| 10 |
st.markdown("""
|
| 11 |
<style>
|
| 12 |
.main {background-color: #f8f9fa;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
div[data-testid="stVerticalBlock"] {gap: 0.2rem;}
|
| 14 |
div[data-testid="stHorizontalBlock"] {gap: 0.3rem;}
|
| 15 |
.stTextArea textarea, .stTextInput input {
|
| 16 |
+
padding: 0.3rem;
|
| 17 |
+
font-size: 0.85em;
|
| 18 |
}
|
| 19 |
+
h1, h2, h3 {margin-top: 0; margin-bottom: 0.2rem;}
|
| 20 |
+
p, div {margin-bottom: 0.1rem;}
|
| 21 |
+
.category-header {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
font-weight: bold;
|
| 23 |
+
font-size: 1rem;
|
| 24 |
+
margin-bottom: 0.2rem;
|
| 25 |
color: #333;
|
| 26 |
+
background-color: #f1f8ff;
|
| 27 |
+
padding: 3px 8px;
|
| 28 |
+
border-radius: 4px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
.prompt-display {
|
| 31 |
background-color: #ffffff;
|
| 32 |
border-radius: 4px;
|
| 33 |
+
padding: 12px;
|
| 34 |
border: 1px solid #e9ecef;
|
| 35 |
+
min-height: 150px;
|
|
|
|
| 36 |
white-space: pre-wrap;
|
| 37 |
}
|
| 38 |
+
.st-emotion-cache-1nv1tyf {
|
| 39 |
+
font-size: 0.85rem;
|
| 40 |
+
}
|
| 41 |
+
.dataframe-container {
|
| 42 |
+
background-color: white;
|
| 43 |
+
border: 1px solid #e6e6e6;
|
| 44 |
+
border-radius: 4px;
|
| 45 |
+
padding: 8px;
|
| 46 |
+
margin-bottom: 8px;
|
| 47 |
+
}
|
| 48 |
+
.selected-item {
|
| 49 |
+
background-color: #007bff !important;
|
| 50 |
+
color: white !important;
|
| 51 |
+
font-weight: bold;
|
| 52 |
+
padding: 2px 6px;
|
| 53 |
+
border-radius: 4px;
|
| 54 |
+
}
|
| 55 |
+
.unselected-item {
|
| 56 |
+
background-color: #f8f9fa;
|
| 57 |
+
padding: 2px 6px;
|
| 58 |
+
border-radius: 4px;
|
| 59 |
+
cursor: pointer;
|
| 60 |
+
}
|
| 61 |
+
.unselected-item:hover {
|
| 62 |
+
background-color: #e9ecef;
|
| 63 |
+
}
|
| 64 |
+
table {
|
| 65 |
+
font-size: 0.85rem;
|
| 66 |
+
}
|
| 67 |
+
.clickable {
|
| 68 |
+
cursor: pointer;
|
| 69 |
+
}
|
| 70 |
</style>
|
| 71 |
""", unsafe_allow_html=True)
|
| 72 |
|
| 73 |
+
# Initialize session state
|
| 74 |
if 'selections' not in st.session_state:
|
| 75 |
st.session_state.selections = {
|
| 76 |
'role': None, 'tone': None, 'instruction': None, 'length': None,
|
|
|
|
| 78 |
'about': "", 'inclusion': "", 'exclusion': "", 'input_data': ""
|
| 79 |
}
|
| 80 |
|
| 81 |
+
# Data sets with emoji and names
|
| 82 |
data = {
|
| 83 |
'roles': [
|
| 84 |
{"name": "Professional", "emoji": "๐"}, {"name": "Expert", "emoji": "๐ง "},
|
|
|
|
| 134 |
]
|
| 135 |
}
|
| 136 |
|
| 137 |
+
# Function to convert data to dataframe rows
|
| 138 |
+
def create_dataframe_rows(items, cols=4):
|
| 139 |
+
# Calculate how many rows we need based on items and columns
|
| 140 |
+
num_rows = (len(items) + cols - 1) // cols
|
| 141 |
+
|
| 142 |
+
# Create empty rows
|
| 143 |
+
rows = [["" for _ in range(cols)] for _ in range(num_rows)]
|
| 144 |
|
| 145 |
+
# Fill in the values
|
| 146 |
for i, item in enumerate(items):
|
| 147 |
+
row_idx = i // cols
|
| 148 |
+
col_idx = i % cols
|
| 149 |
+
rows[row_idx][col_idx] = f"{item['emoji']} {item['name']}"
|
| 150 |
+
|
| 151 |
+
return rows
|
| 152 |
+
|
| 153 |
+
# Function to handle cell click events
|
| 154 |
+
def handle_selection(category, value):
|
| 155 |
+
# Extract the name without emoji
|
| 156 |
+
parts = value.split(' ', 1)
|
| 157 |
+
if len(parts) < 2:
|
| 158 |
+
return
|
| 159 |
+
|
| 160 |
+
emoji = parts[0]
|
| 161 |
+
name = parts[1]
|
| 162 |
+
|
| 163 |
+
# Find the item in the data
|
| 164 |
+
for item in data[f"{category}s"]:
|
| 165 |
+
if item['name'] == name:
|
| 166 |
+
st.session_state.selections[category] = item
|
| 167 |
+
return
|
| 168 |
+
|
| 169 |
+
# If not found (shouldn't happen)
|
| 170 |
+
st.session_state.selections[category] = {"name": name, "emoji": emoji}
|
| 171 |
+
|
| 172 |
+
# Function to create dataframe with click handler
|
| 173 |
+
def create_dataframe_category(category, title, emoji_prefix):
|
| 174 |
+
# Create the dataframe content
|
| 175 |
+
df_rows = create_dataframe_rows(data[f"{category}s"], cols=4)
|
| 176 |
+
df = pd.DataFrame(df_rows)
|
| 177 |
+
|
| 178 |
+
# Display the category header
|
| 179 |
+
st.markdown(f"<div class='category-header'>{emoji_prefix} {title}</div>", unsafe_allow_html=True)
|
| 180 |
+
|
| 181 |
+
# Display in a container
|
| 182 |
+
st.markdown(f"<div class='dataframe-container'>", unsafe_allow_html=True)
|
| 183 |
+
|
| 184 |
+
# Use an edited dataframe
|
| 185 |
+
edited_df = st.data_editor(
|
| 186 |
+
df,
|
| 187 |
+
key=f"df_{category}",
|
| 188 |
+
hide_index=True,
|
| 189 |
+
column_config={
|
| 190 |
+
i: st.column_config.Column(
|
| 191 |
+
label=f"Option {i+1}",
|
| 192 |
+
width="small",
|
| 193 |
+
) for i in range(df.shape[1])
|
| 194 |
+
},
|
| 195 |
+
disabled=True,
|
| 196 |
+
use_container_width=True,
|
| 197 |
+
on_click=lambda e: handle_selection(category, e.current)
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
# Check if there's a selected value to highlight
|
| 201 |
+
if st.session_state.selections[category]:
|
| 202 |
+
selected_value = f"{st.session_state.selections[category]['emoji']} {st.session_state.selections[category]['name']}"
|
| 203 |
+
# Since we can't style specific cells in the dataframe editor, we can indicate the selection another way
|
| 204 |
+
selected_index = None
|
| 205 |
+
for i, row in df.iterrows():
|
| 206 |
+
for j, cell in enumerate(row):
|
| 207 |
+
if cell == selected_value:
|
| 208 |
+
selected_index = (i, j)
|
| 209 |
+
break
|
| 210 |
+
if selected_index:
|
| 211 |
+
break
|
| 212 |
|
| 213 |
+
if selected_index:
|
| 214 |
+
st.markdown(f"Selected: **{selected_value}**", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 217 |
|
| 218 |
+
# Function to generate the final prompt
|
| 219 |
+
def generate_prompt():
|
| 220 |
+
sel = st.session_state.selections
|
| 221 |
+
|
| 222 |
+
# Check if all required fields are selected
|
| 223 |
+
if not all([sel['role'], sel['tone'], sel['instruction'], sel['length'],
|
| 224 |
+
sel['content_type'], sel['audience'], sel['format'], sel['about']]):
|
| 225 |
+
return "Please select all required components and provide a topic."
|
| 226 |
+
|
| 227 |
+
# Generate the prompt
|
| 228 |
+
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']}.
|
| 229 |
+
|
| 230 |
+
It should be about {sel['about']}."""
|
| 231 |
+
|
| 232 |
+
if sel['inclusion']:
|
| 233 |
+
prompt += f"\nInclude {sel['inclusion']}."
|
| 234 |
+
|
| 235 |
+
if sel['exclusion']:
|
| 236 |
+
prompt += f"\nExclude {sel['exclusion']}."
|
| 237 |
+
|
| 238 |
+
prompt += f"\n\nReturn the output as {sel['format']['emoji']} {sel['format']['name']}."
|
| 239 |
+
|
| 240 |
+
if sel['input_data']:
|
| 241 |
+
prompt += f"\nUse the following information: {sel['input_data']}"
|
| 242 |
+
|
| 243 |
+
return prompt
|
| 244 |
+
|
| 245 |
+
# Header
|
| 246 |
+
st.markdown("<h2 style='text-align: center; font-size: 1.3rem; margin-bottom: 1rem;'>๐ง ChatGPT Prompt Generator</h2>", unsafe_allow_html=True)
|
| 247 |
|
| 248 |
# Main layout with two columns
|
| 249 |
+
col1, col2 = st.columns([3, 1])
|
| 250 |
|
| 251 |
+
with col1:
|
| 252 |
+
# Create dataframes for each category
|
| 253 |
+
create_dataframe_category("role", "Choose a Role", "๐ค")
|
| 254 |
+
create_dataframe_category("tone", "Select a Tone", "๐ญ")
|
| 255 |
+
create_dataframe_category("instruction", "Select an Instruction", "๐")
|
| 256 |
+
create_dataframe_category("length", "Select Length", "๐")
|
| 257 |
+
create_dataframe_category("content_type", "Select Content Type", "๐")
|
| 258 |
+
create_dataframe_category("audience", "Select Target Audience", "๐ฅ")
|
| 259 |
+
create_dataframe_category("format", "Select Format", "๐")
|
| 260 |
+
|
| 261 |
+
# Text input fields
|
| 262 |
+
st.markdown("<div class='category-header'>๐ Additional Details</div>", unsafe_allow_html=True)
|
| 263 |
+
st.markdown("<div class='dataframe-container'>", unsafe_allow_html=True)
|
| 264 |
+
|
| 265 |
+
st.session_state.selections['about'] = st.text_input("๐ฌ Topic",
|
| 266 |
+
value=st.session_state.selections['about'],
|
| 267 |
+
placeholder="Enter what the content should be about")
|
| 268 |
+
|
|
|
|
|
|
|
|
|
|
| 269 |
col1, col2 = st.columns(2)
|
| 270 |
with col1:
|
| 271 |
+
st.session_state.selections['inclusion'] = st.text_input("โ
Include",
|
| 272 |
+
value=st.session_state.selections['inclusion'],
|
| 273 |
+
placeholder="What to include in the content")
|
|
|
|
| 274 |
|
| 275 |
with col2:
|
| 276 |
+
st.session_state.selections['exclusion'] = st.text_input("โ Exclude",
|
| 277 |
+
value=st.session_state.selections['exclusion'],
|
| 278 |
+
placeholder="What to exclude from the content")
|
| 279 |
+
|
| 280 |
+
st.session_state.selections['input_data'] = st.text_area("๐ Input Data",
|
| 281 |
+
value=st.session_state.selections['input_data'],
|
| 282 |
+
placeholder="Enter any specific information to use",
|
| 283 |
+
height=100)
|
| 284 |
+
|
| 285 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
|
| 287 |
+
with col2:
|
| 288 |
+
# Generate the prompt
|
| 289 |
+
prompt = generate_prompt()
|
| 290 |
+
|
| 291 |
+
# Display the prompt
|
| 292 |
+
st.markdown("<div class='category-header'>๐ฎ Generated Prompt</div>", unsafe_allow_html=True)
|
| 293 |
+
st.markdown("<div class='dataframe-container'>", unsafe_allow_html=True)
|
| 294 |
+
st.markdown("<div class='prompt-display'>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
st.write(prompt)
|
| 296 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 297 |
|
| 298 |
+
# Action buttons
|
| 299 |
+
btn1, btn2, btn3 = st.columns(3)
|
| 300 |
+
with btn1:
|
| 301 |
if st.button("๐ Copy", type="primary", use_container_width=True):
|
| 302 |
st.code(prompt, language="")
|
| 303 |
|
| 304 |
+
with btn2:
|
| 305 |
if st.button("๐ Reset", type="secondary", use_container_width=True):
|
| 306 |
for key in st.session_state.selections:
|
| 307 |
if key in ['about', 'inclusion', 'exclusion', 'input_data']:
|
|
|
|
| 310 |
st.session_state.selections[key] = None
|
| 311 |
st.experimental_rerun()
|
| 312 |
|
| 313 |
+
with btn3:
|
| 314 |
if st.button("๐ฒ Random", type="secondary", use_container_width=True):
|
| 315 |
for category in ['role', 'tone', 'instruction', 'length', 'content_type', 'audience', 'format']:
|
| 316 |
st.session_state.selections[category] = random.choice(data[category+'s'])
|
| 317 |
st.experimental_rerun()
|
| 318 |
|
| 319 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 320 |
|
| 321 |
+
# Sample prompts section
|
| 322 |
+
st.markdown("<div class='category-header'>๐ Examples</div>", unsafe_allow_html=True)
|
| 323 |
+
st.markdown("<div class='dataframe-container'>", unsafe_allow_html=True)
|
| 324 |
|
| 325 |
+
# Example 1
|
| 326 |
st.markdown("""
|
| 327 |
+
<div style="background-color: #e6f3ff; border: 1px solid #b8daff; border-radius: 4px; padding: 6px; margin-bottom: 6px; font-size: 0.8em;">
|
| 328 |
+
<b>๐จโ๐ซ Teaching</b><pre style="white-space: pre-wrap; font-size: 0.8em; margin: 3px 0px;">Act as a ๐จโ๐ซ Teacher, use ๐ Informative tone, Create a ๐ Guide for ๐ฑ Beginners.
|
| 329 |
|
| 330 |
It should be about Git.
|
| 331 |
Include practical examples.
|
|
|
|
| 333 |
|
| 334 |
Return as ๐ Markdown.</pre>
|
| 335 |
</div>
|
| 336 |
+
""", unsafe_allow_html=True)
|
| 337 |
|
| 338 |
+
# Example 2
|
| 339 |
+
st.markdown("""
|
| 340 |
+
<div style="background-color: #e6ffed; border: 1px solid #b8e6cc; border-radius: 4px; padding: 6px; margin-bottom: 6px; font-size: 0.8em;">
|
| 341 |
+
<b>๐ผ Business</b><pre style="white-space: pre-wrap; font-size: 0.8em; margin: 3px 0px;">Act as a ๐ Professional, use ๐ค Persuasive tone, Write a ๐ง Email for ๐ฉโ๐ผ Executives.
|
| 342 |
|
| 343 |
It should be about a product launch.
|
| 344 |
Include ROI metrics.
|
|
|
|
| 346 |
|
| 347 |
Return as ๐ Plain Text.</pre>
|
| 348 |
</div>
|
| 349 |
+
""", unsafe_allow_html=True)
|
| 350 |
|
| 351 |
+
# Prompt structure guide
|
| 352 |
+
st.markdown("""
|
| 353 |
+
<div style="background-color: #f1f8ff; border-radius: 4px; padding: 6px; margin-top: 6px; font-size: 0.8em;">
|
| 354 |
+
<b>Prompt Structure:</b><br>
|
| 355 |
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>
|
| 356 |
It should be about [TOPIC].<br>
|
| 357 |
Include [INCLUSION]. Exclude [EXCLUSION].<br>
|
|
|
|
| 359 |
</div>
|
| 360 |
""", unsafe_allow_html=True)
|
| 361 |
|
| 362 |
+
st.markdown("</div>", unsafe_allow_html=True)
|