JeCabrera commited on
Commit
6f19708
verified
1 Parent(s): 5aecc48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -12
app.py CHANGED
@@ -25,6 +25,8 @@ if 'submitted' not in st.session_state:
25
  st.session_state.submitted = False
26
  if 'offer_result' not in st.session_state:
27
  st.session_state.offer_result = ""
 
 
28
 
29
  # Hide Streamlit menu and footer
30
  st.markdown("""
@@ -141,6 +143,7 @@ with col1:
141
  return
142
 
143
  st.session_state.submitted = True
 
144
 
145
  # Store inputs based on what's available
146
  if has_manual_input:
@@ -176,7 +179,7 @@ with col1:
176
 
177
  # Results column
178
  with col2:
179
- if st.session_state.submitted:
180
  with st.spinner('Creando tu oferta perfecta...'):
181
  base_prompt = f"""You are a professional copywriter specializing in creating irresistible offers.
182
  Create a compelling and persuasive offer using the {st.session_state.formula_type} formula.
@@ -250,21 +253,25 @@ with col2:
250
  response = model.generate_content(prompt, generation_config=generation_config)
251
 
252
  st.session_state.offer_result = response.text
 
253
 
254
- st.markdown('### Oferta Generada')
255
- st.markdown(st.session_state.offer_result)
256
-
257
- col_download, col_empty = st.columns([8, 2])
258
- with col_download:
259
- st.download_button(
260
- label="Descargar Oferta",
261
- data=st.session_state.offer_result,
262
- file_name="oferta_generada.txt",
263
- mime="text/plain"
264
- )
265
  except Exception as e:
266
  st.error(f'Ocurri贸 un error: {str(e)}')
267
  st.session_state.submitted = False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
 
269
  # Footer
270
  st.markdown('---')
 
25
  st.session_state.submitted = False
26
  if 'offer_result' not in st.session_state:
27
  st.session_state.offer_result = ""
28
+ if 'generated' not in st.session_state:
29
+ st.session_state.generated = False
30
 
31
  # Hide Streamlit menu and footer
32
  st.markdown("""
 
143
  return
144
 
145
  st.session_state.submitted = True
146
+ st.session_state.generated = False # Reset generated flag
147
 
148
  # Store inputs based on what's available
149
  if has_manual_input:
 
179
 
180
  # Results column
181
  with col2:
182
+ if st.session_state.submitted and not st.session_state.generated:
183
  with st.spinner('Creando tu oferta perfecta...'):
184
  base_prompt = f"""You are a professional copywriter specializing in creating irresistible offers.
185
  Create a compelling and persuasive offer using the {st.session_state.formula_type} formula.
 
253
  response = model.generate_content(prompt, generation_config=generation_config)
254
 
255
  st.session_state.offer_result = response.text
256
+ st.session_state.generated = True # Mark as generated
257
 
 
 
 
 
 
 
 
 
 
 
 
258
  except Exception as e:
259
  st.error(f'Ocurri贸 un error: {str(e)}')
260
  st.session_state.submitted = False
261
+
262
+ # Display results if we have an offer result
263
+ if st.session_state.generated:
264
+ st.markdown('### Oferta Generada')
265
+ st.markdown(st.session_state.offer_result)
266
+
267
+ col_download, col_empty = st.columns([8, 2])
268
+ with col_download:
269
+ st.download_button(
270
+ label="Descargar Oferta",
271
+ data=st.session_state.offer_result,
272
+ file_name="oferta_generada.txt",
273
+ mime="text/plain"
274
+ )
275
 
276
  # Footer
277
  st.markdown('---')