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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -34
app.py CHANGED
@@ -90,23 +90,27 @@ def generate_bullets(number_of_bullets, target_audience, product, call_to_action
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")
104
 
105
- # A帽adir t铆tulo y subt铆tulo usando HTML y aplicando estilo directamente
106
  st.markdown("<h1 style='text-align: center;'>Impact Bullet Generator</h1>", unsafe_allow_html=True)
107
  st.markdown("<h4 style='text-align: center;'>Transforma los pensamientos de tu audiencia en balas persuasivas que inspiren a la acci贸n.</h4>", unsafe_allow_html=True)
108
 
109
- # A帽adir CSS personalizado para el bot贸n y estilo general
110
  st.markdown("""
111
  <style>
112
  div.stButton > button {
@@ -126,26 +130,11 @@ st.markdown("""
126
  background-color: #FFD700;
127
  color: black;
128
  }
129
- .generated-bullets {
130
- border: 1px solid #000000;
131
- padding: 10px;
132
- border-radius: 8px;
133
- background-color: #f9f9f9;
134
- margin-top: 20px;
135
- }
136
- .generated-bullets h4 {
137
- margin-bottom: 10px;
138
- font-weight: bold;
139
- }
140
- .generated-bullets p {
141
- margin: 0;
142
- font-size: 16px;
143
- }
144
  </style>
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,18 +153,13 @@ if submit:
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:
179
  st.error(f"Error al generar los bullets: {str(e)}")
180
  else:
181
- st.error("Por favor, completa todos los campos.")
 
90
  generation_config=generation_config,
91
  )
92
 
93
+ # Generar el resultado utilizando el modelo
94
+ try:
95
+ response = model.generate_content([system_instruction])
96
+
97
+ # Verificar que la respuesta tenga el formato esperado
98
+ if response.candidates and response.candidates[0].content.parts:
99
+ generated_bullets = response.candidates[0].content.parts[0].text.strip()
100
+ return generated_bullets
101
+ else:
102
+ raise ValueError("No se generaron bullets v谩lidos.")
103
+ except Exception as e:
104
+ raise ValueError(f"Error al generar los bullets: {str(e)}")
105
 
106
  # Configurar la interfaz de usuario con Streamlit
107
  st.set_page_config(page_title="Quick Prompt", layout="wide")
108
 
109
+ # Centrar el t铆tulo y el subt铆tulo
110
  st.markdown("<h1 style='text-align: center;'>Impact Bullet Generator</h1>", unsafe_allow_html=True)
111
  st.markdown("<h4 style='text-align: center;'>Transforma los pensamientos de tu audiencia en balas persuasivas que inspiren a la acci贸n.</h4>", unsafe_allow_html=True)
112
 
113
+ # A帽adir CSS personalizado para el bot贸n
114
  st.markdown("""
115
  <style>
116
  div.stButton > button {
 
130
  background-color: #FFD700;
131
  color: black;
132
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  </style>
134
  """, unsafe_allow_html=True)
135
 
136
  # Crear columnas
137
+ col1, col2 = st.columns([1, 2])
138
 
139
  # Columnas de entrada
140
  with col1:
 
153
  try:
154
  # Obtener la respuesta del modelo
155
  generated_bullets = generate_bullets(number_of_bullets, target_audience, product, call_to_action, temperature)
 
 
 
 
 
156
  col2.markdown(f"""
157
+ <div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;">
158
  <h4>Mira los bullets generados:</h4>
159
+ <p>{generated_bullets}</p>
160
  </div>
161
  """, unsafe_allow_html=True)
162
  except Exception as e:
163
  st.error(f"Error al generar los bullets: {str(e)}")
164
  else:
165
+ st.error("Por favor, completa todos los campos.")