JeCabrera commited on
Commit
1919f68
·
verified ·
1 Parent(s): c4a09e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -22
app.py CHANGED
@@ -90,27 +90,14 @@ def generate_bullets(number_of_bullets, target_audience, product, call_to_action
90
  generation_config=generation_config,
91
  )
92
 
93
- # Mostrar los beneficios generados con formato correcto en HTML
94
- if "submit" in locals() and submit:
95
- if target_audience and product and call_to_action:
96
- try:
97
- # Obtener la respuesta del modelo
98
- generated_bullets = generate_bullets(number_of_bullets, target_audience, product, call_to_action, temperature)
99
-
100
- # Dividir los bullets por líneas y generar el HTML sin formato markdown
101
- bullets_list = generated_bullets.split("*")
102
- bullets_html = "".join([f"<li>{bullet.strip()}</li>" for bullet in bullets_list if bullet.strip()])
103
 
104
- col2.markdown(f"""
105
- <div class="generated-bullets">
106
- <h4>Mira los bullets generados:</h4>
107
- <ul>{bullets_html}</ul>
108
- </div>
109
- """, unsafe_allow_html=True)
110
- except Exception as e:
111
- st.error(f"Error al generar los bullets: {str(e)}")
112
- else:
113
- st.error("Por favor, completa todos los campos.")
114
 
115
  # Configurar la interfaz de usuario con Streamlit
116
  st.set_page_config(page_title="Quick Prompt", layout="wide")
@@ -158,7 +145,7 @@ st.markdown("""
158
  """, unsafe_allow_html=True)
159
 
160
  # Crear columnas
161
- col1, col2 = st.columns([1, 2])
162
 
163
  # Columnas de entrada
164
  with col1:
@@ -177,10 +164,15 @@ if submit:
177
  try:
178
  # Obtener la respuesta del modelo
179
  generated_bullets = generate_bullets(number_of_bullets, target_audience, product, call_to_action, temperature)
 
 
 
 
 
180
  col2.markdown(f"""
181
  <div class="generated-bullets">
182
  <h4>Mira los bullets generados:</h4>
183
- <p>{generated_bullets}</p>
184
  </div>
185
  """, unsafe_allow_html=True)
186
  except Exception as e:
 
90
  generation_config=generation_config,
91
  )
92
 
93
+ # Obtener respuesta generada
94
+ response = model.generate(
95
+ instruction=system_instruction,
96
+ examples=benefit_types,
97
+ )
 
 
 
 
 
98
 
99
+ # Retornar los bullets generados
100
+ return response.generations[0].text
 
 
 
 
 
 
 
 
101
 
102
  # Configurar la interfaz de usuario con Streamlit
103
  st.set_page_config(page_title="Quick Prompt", layout="wide")
 
145
  """, unsafe_allow_html=True)
146
 
147
  # Crear columnas
148
+ col1, col2 = st.columns([1, 2])
149
 
150
  # Columnas de entrada
151
  with col1:
 
164
  try:
165
  # Obtener la respuesta del modelo
166
  generated_bullets = generate_bullets(number_of_bullets, target_audience, product, call_to_action, temperature)
167
+
168
+ # Dividir los bullets por líneas y generar el HTML sin formato markdown
169
+ bullets_list = generated_bullets.split("*")
170
+ bullets_html = "".join([f"<li>{bullet.strip()}</li>" for bullet in bullets_list if bullet.strip()])
171
+
172
  col2.markdown(f"""
173
  <div class="generated-bullets">
174
  <h4>Mira los bullets generados:</h4>
175
+ <ul>{bullets_html}</ul>
176
  </div>
177
  """, unsafe_allow_html=True)
178
  except Exception as e: