Spaces:
Sleeping
Sleeping
Update app.py
Browse files89 unmodified lines9091929394959697989910010110210310410510610710810911011111213 unmodified lines12612712812913013113213313413513613713813914014114214314414514614714814915015112 unmodified lines16416516616716816917017117217317417517617717817918018189 unmodified linesgeneration_config=generation_config,)# Obtener respuesta generadaresponse = model.generate(instruction=system_instruction,examples=benefit_types,)# Retornar los bullets generadosreturn response.generations[0].text# Configurar la interfaz de usuario con Streamlitst.set_page_config(page_title="Quick Prompt", layout="wide")# Añadir título y subtítulo usando HTML y aplicando estilo directamentest.markdown("<h1 style='text-align: center;'>Impact Bullet Generator</h1>", unsafe_allow_html=True)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)# Añadir CSS personalizado para el botón y estilo generalst.markdown("""<style>div.stButton > button {13 unmodified linesbackground-color: #FFD700;color: black;}.generated-bullets {border: 1px solid #000000;padding: 10px;border-radius: 8px;background-color: #f9f9f9;margin-top: 20px;}.generated-bullets h4 {margin-bottom: 10px;font-weight: bold;}.generated-bullets p {margin: 0;font-size: 16px;}</style>""", unsafe_allow_html=True)# Crear columnascol1, col2 = st.columns([1, 2])# Columnas de entradawith col1:12 unmodified linestry:# Obtener la respuesta del modelogenerated_bullets = generate_bullets(number_of_bullets, target_audience, product, call_to_action, temperature)# Dividir los bullets por líneas y generar el HTML sin formato markdownbullets_list = generated_bullets.split("*")bullets_html = "".join([f"<li>{bullet.strip()}</li>" for bullet in bullets_list if bullet.strip()])col2.markdown(f"""<div class="generated-bullets"><h4>Mira los bullets generados:</h4><ul>{bullets_html}</ul></div>""", unsafe_allow_html=True)except Exception as e:st.error(f"Error al generar los bullets: {str(e)}")else:st.error("Por favor, completa todos los campos.")89 unmodified lines9091929394959697989910010110210310410510610710810911011111211311411511613 unmodified lines13013113213313413513613713813914012 unmodified lines15315415515615715815916016116216316416589 unmodified linesgeneration_config=generation_config,)# Generar el resultado utilizando el modelotry:response = model.generate_content([system_instruction])# Verificar que la respuesta tenga el formato esperadoif response.candidates and response.candidates[0].content.parts:generated_bullets = response.candidates[0].content.parts[0].text.strip()return generated_bulletselse:raise ValueError("No se generaron bullets válidos.")except Exception as e:raise ValueError(f"Error al generar los bullets: {str(e)}")# Configurar la interfaz de usuario con Streamlitst.set_page_config(page_title="Quick Prompt", layout="wide")# Centrar el título y el subtítulost.markdown("<h1 style='text-align: center;'>Impact Bullet Generator</h1>", unsafe_allow_html=True)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)# Añadir CSS personalizado para el botónst.markdown("""<style>div.stButton > button {13 unmodified linesbackground-color: #FFD700;color: black;}</style>""", unsafe_allow_html=True)# Crear columnascol1, col2 = st.columns([1, 2])# Columnas de entradawith col1:12 unmodified linestry:# Obtener la respuesta del modelogenerated_bullets = generate_bullets(number_of_bullets, target_audience, product, call_to_action, temperature)col2.markdown(f"""<div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;"><h4>Mira los bullets generados:</h4><p>{generated_bullets}</p></div>""", unsafe_allow_html=True)except Exception as e:st.error(f"Error al generar los bullets: {str(e)}")else:st.error("Por favor, completa todos los campos.")
app.py+18-34