awacke1 commited on
Commit
4645ced
ยท
verified ยท
1 Parent(s): 7248d58

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -12
app.py CHANGED
@@ -7,7 +7,7 @@ from datetime import datetime
7
  import base64
8
 
9
  # Set page configuration
10
- st.set_page_config(page_title="ChatGPT Prompt Generator", page_icon="๐Ÿง ", layout="wide")
11
 
12
  # Custom CSS for styling
13
  st.markdown("""
@@ -37,6 +37,7 @@ st.markdown("""
37
  border: 1px solid #e9ecef;
38
  min-height: 150px;
39
  white-space: pre-wrap;
 
40
  }
41
  .st-emotion-cache-1nv1tyf {
42
  font-size: 0.85rem;
@@ -73,12 +74,13 @@ st.markdown("""
73
  </style>
74
  """, unsafe_allow_html=True)
75
 
76
- # Initialize session state
77
  if 'selections' not in st.session_state:
78
  st.session_state.selections = {
79
  'role': None, 'tone': None, 'instruction': None, 'length': None,
80
  'content_type': None, 'audience': None, 'format': None,
81
- 'about': "", 'inclusion': "", 'exclusion': "", 'input_data': ""
 
82
  }
83
  if 'prompt_history' not in st.session_state:
84
  st.session_state.prompt_history = []
@@ -135,7 +137,9 @@ data = {
135
  {"name": "Markdown", "emoji": "๐Ÿ“"}, {"name": "HTML", "emoji": "๐ŸŒ"},
136
  {"name": "Plain Text", "emoji": "๐Ÿ“„"}, {"name": "JSON", "emoji": "๐Ÿ”„"},
137
  {"name": "PDF", "emoji": "๐Ÿ“‘"}, {"name": "Python Code", "emoji": "๐Ÿ"},
138
- {"name": "JavaScript", "emoji": "๐Ÿ“œ"}, {"name": "SQL Query", "emoji": "๐Ÿ’พ"}
 
 
139
  ]
140
  }
141
 
@@ -166,8 +170,8 @@ def generate_prompt():
166
  sel = st.session_state.selections
167
 
168
  if not all([sel['role'], sel['tone'], sel['instruction'], sel['length'],
169
- sel['content_type'], sel['audience'], sel['format'], sel['about']]):
170
- return "Please select all required components and provide a topic."
171
 
172
  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']}.
173
 
@@ -218,19 +222,28 @@ def get_base64_download_link(filepath):
218
  filename = os.path.basename(filepath)
219
  return f'<a href="data:application/octet-stream;base64,{b64}" download="{filename}">Download {filename}</a>'
220
 
221
- # Sidebar for File History
222
  with st.sidebar:
223
  st.markdown("### ๐Ÿ“ Saved Prompts")
224
  md_files = get_saved_md_files()
225
  if md_files:
226
- for md_file in sorted(md_files, reverse=True): # Newest first
227
  filepath = os.path.join("prompts", md_file)
228
  st.markdown(f"- {get_base64_download_link(filepath)}", unsafe_allow_html=True)
229
  else:
230
  st.write("No saved prompts yet.")
 
 
 
 
 
 
 
 
 
231
 
232
  # Header
233
- st.markdown("<h2 style='text-align: center; font-size: 1.3rem; margin-bottom: 1rem;'>๐Ÿง  ChatGPT Prompt Generator</h2>", unsafe_allow_html=True)
234
 
235
  # Main layout with two columns
236
  col1, col2 = st.columns([3, 1])
@@ -273,8 +286,8 @@ with col2:
273
 
274
  st.markdown("<div class='category-header'>๐Ÿ”ฎ Generated Prompt</div>", unsafe_allow_html=True)
275
  st.markdown("<div class='dataframe-container'>", unsafe_allow_html=True)
276
- st.markdown("<div class='prompt-display'>", unsafe_allow_html=True)
277
- st.write(prompt)
278
  st.markdown("</div>", unsafe_allow_html=True)
279
 
280
  button_cols = st.columns(4)
@@ -285,7 +298,7 @@ with col2:
285
  if st.button("๐Ÿ”„ Reset", type="secondary", use_container_width=True):
286
  for key in st.session_state.selections:
287
  if key in ['about', 'inclusion', 'exclusion', 'input_data']:
288
- st.session_state.selections[key] = ""
289
  else:
290
  st.session_state.selections[key] = None
291
  st.session_state.prompt_history = []
 
7
  import base64
8
 
9
  # Set page configuration
10
+ st.set_page_config(page_title="PromptWizardry", page_icon="๐Ÿง ", layout="wide")
11
 
12
  # Custom CSS for styling
13
  st.markdown("""
 
37
  border: 1px solid #e9ecef;
38
  min-height: 150px;
39
  white-space: pre-wrap;
40
+ font-size: 0.85em;
41
  }
42
  .st-emotion-cache-1nv1tyf {
43
  font-size: 0.85rem;
 
74
  </style>
75
  """, unsafe_allow_html=True)
76
 
77
+ # Initialize session state with default topic
78
  if 'selections' not in st.session_state:
79
  st.session_state.selections = {
80
  'role': None, 'tone': None, 'instruction': None, 'length': None,
81
  'content_type': None, 'audience': None, 'format': None,
82
+ 'about': "DistillKit, MergeKit, Spectrum for ML Model Building from input Spreadsheets using torch, transformers and Streamlit",
83
+ 'inclusion': "", 'exclusion': "", 'input_data': ""
84
  }
85
  if 'prompt_history' not in st.session_state:
86
  st.session_state.prompt_history = []
 
137
  {"name": "Markdown", "emoji": "๐Ÿ“"}, {"name": "HTML", "emoji": "๐ŸŒ"},
138
  {"name": "Plain Text", "emoji": "๐Ÿ“„"}, {"name": "JSON", "emoji": "๐Ÿ”„"},
139
  {"name": "PDF", "emoji": "๐Ÿ“‘"}, {"name": "Python Code", "emoji": "๐Ÿ"},
140
+ {"name": "JavaScript", "emoji": "๐Ÿ“œ"}, {"name": "SQL Query", "emoji": "๐Ÿ’พ"},
141
+ {"name": "Image Gen Prompt", "emoji": "๐Ÿ–ผ๏ธ"}, {"name": "Video Gen Prompt", "emoji": "๐ŸŽฅ"},
142
+ {"name": "Song Gen Prompt", "emoji": "๐ŸŽต"}, {"name": "Story Gen Prompt", "emoji": "๐Ÿ“š"}
143
  ]
144
  }
145
 
 
170
  sel = st.session_state.selections
171
 
172
  if not all([sel['role'], sel['tone'], sel['instruction'], sel['length'],
173
+ sel['content_type'], sel['audience'], sel['format']]):
174
+ return "Please select all required components."
175
 
176
  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']}.
177
 
 
222
  filename = os.path.basename(filepath)
223
  return f'<a href="data:application/octet-stream;base64,{b64}" download="{filename}">Download {filename}</a>'
224
 
225
+ # Sidebar with Saved Prompts and Feature Outline
226
  with st.sidebar:
227
  st.markdown("### ๐Ÿ“ Saved Prompts")
228
  md_files = get_saved_md_files()
229
  if md_files:
230
+ for md_file in sorted(md_files, reverse=True):
231
  filepath = os.path.join("prompts", md_file)
232
  st.markdown(f"- {get_base64_download_link(filepath)}", unsafe_allow_html=True)
233
  else:
234
  st.write("No saved prompts yet.")
235
+
236
+ st.markdown("### ๐ŸŒŸ PromptWizardry Magic")
237
+ st.markdown("""
238
+ - ๐ŸŒˆ **Prompt Alchemy**: Craft with roles, tones, & more!
239
+ - ๐Ÿช„ **Actions**: Copy, Reset, Random, Run!
240
+ - ๐Ÿ’พ **Scroll Vault**: Save & download `.md` spells!
241
+ - โณ **Chronicles**: Relive your magic history!
242
+ - ๐ŸŽ‰ **Extras**: Sample spells & dazzling UI!
243
+ """)
244
 
245
  # Header
246
+ st.markdown("<h2 style='text-align: center; font-size: 1.3rem; margin-bottom: 1rem;'>โœจ PromptWizardry</h2>", unsafe_allow_html=True)
247
 
248
  # Main layout with two columns
249
  col1, col2 = st.columns([3, 1])
 
286
 
287
  st.markdown("<div class='category-header'>๐Ÿ”ฎ Generated Prompt</div>", unsafe_allow_html=True)
288
  st.markdown("<div class='dataframe-container'>", unsafe_allow_html=True)
289
+ st.text_area("", value=prompt, height=150, key="generated_prompt", disabled=True,
290
+ help="Your magical prompt appears here!")
291
  st.markdown("</div>", unsafe_allow_html=True)
292
 
293
  button_cols = st.columns(4)
 
298
  if st.button("๐Ÿ”„ Reset", type="secondary", use_container_width=True):
299
  for key in st.session_state.selections:
300
  if key in ['about', 'inclusion', 'exclusion', 'input_data']:
301
+ st.session_state.selections[key] = "" if key != 'about' else "DistillKit, MergeKit, Spectrum for ML Model Building from input Spreadsheets using torch, transformers and Streamlit"
302
  else:
303
  st.session_state.selections[key] = None
304
  st.session_state.prompt_history = []