JeCabrera commited on
Commit
4ee7a48
verified
1 Parent(s): 476d239

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -64
app.py CHANGED
@@ -2,7 +2,7 @@ from dotenv import load_dotenv
2
  import streamlit as st
3
  import os
4
  import google.generativeai as genai
5
- import random # Nueva importaci贸n para la selecci贸n aleatoria de menci贸n
6
 
7
  load_dotenv()
8
 
@@ -19,7 +19,7 @@ def get_random_product_mention():
19
 
20
  def get_gemini_response(target_audience, product, text_type, length, mood, model_choice):
21
  # Generar la menci贸n aleatoria
22
- product_mention = random_product_mention() # Asumiendo que tienes esta funci贸n definida
23
  model = genai.GenerativeModel(model_choice)
24
 
25
  # Crear la instrucci贸n de menci贸n basada en la opci贸n seleccionada
@@ -80,65 +80,26 @@ def get_gemini_response(target_audience, product, text_type, length, mood, model
80
  raise ValueError("Lo sentimos, intenta con una combinaci贸n diferente de entradas.")
81
 
82
  # Inicializar la aplicaci贸n Streamlit
83
- st.set_page_config(page_title="Poetic Vision", page_icon=":pencil:", layout="wide") # Configurar el dise帽o en ancho
84
-
85
- # Componentes principales de la UI
86
- st.markdown("<h1 style='text-align: center;'>VisionTales</h1>", unsafe_allow_html=True)
87
- st.markdown("<h3 style='text-align: center;'>Convierte tus ideas en historias inolvidables.</h3>", unsafe_allow_html=True)
88
-
89
- # A帽adir CSS personalizado para el bot贸n
90
- st.markdown("""
91
- <style>
92
- div.stButton > button {
93
- background-color: #FFCC00; /* Color llamativo */
94
- color: black; /* Texto en negro */
95
- width: 90%;
96
- height: 60px;
97
- font-weight: bold;
98
- font-size: 22px; /* Tama帽o m谩s grande */
99
- text-transform: uppercase; /* Texto en may煤sculas */
100
- border: 1px solid #000000; /* Borde negro de 1px */
101
- border-radius: 8px;
102
- display: block;
103
- margin: 0 auto; /* Centramos el bot贸n */
104
- }
105
- div.stButton > button:hover {
106
- background-color: #FFD700; /* Color al pasar el mouse */
107
- color: black; /* Texto sigue en negro */
108
- }
109
- </style>
110
- """, unsafe_allow_html=True)
111
-
112
- # Crear dos columnas para el dise帽o (40% y 60%)
113
- col1, col2 = st.columns([2, 3]) # 2 + 3 = 5 partes en total
114
-
115
- with col1:
116
- # Entradas del usuario
117
- target_audience = st.text_input("P煤blico objetivo:", placeholder="Especifica tu p煤blico aqu铆...")
118
- product = st.text_input("Producto:", placeholder="Especifica el producto aqu铆...")
119
-
120
- # Agrupar todas las opciones en una acorde贸n
121
- with st.expander("Personaliza tu texto"):
122
-
123
- # Opciones actualizadas para el tipo de texto
124
- text_type = st.selectbox("Tipo de texto:", ["Historia", "Carta de venta", "Correo", "Landing page"])
125
- length = st.selectbox("Longitud del texto:", ["Corto", "Largo"])
126
- mood = st.selectbox("Tono del Texto:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Rom谩ntico"])
127
-
128
- # Opci贸n para seleccionar el modelo
129
- model_choice = st.selectbox("Selecciona el modelo:", ["gemini-1.5-flash", "gemini-1.5-pro"], index=0)
130
-
131
- # Bot贸n para generar contenido
132
- submit = st.button("Escribir mi historia")
133
-
134
- # Manejo del clic en el bot贸n
135
- if submit:
136
- if target_audience and product: # Verificar que se haya proporcionado el p煤blico objetivo y el producto
137
- try:
138
- response = get_gemini_response(target_audience, product, text_type, length, mood, model_choice)
139
- col2.subheader("Contenido generado:")
140
- col2.write(response)
141
- except ValueError as e:
142
- col2.error(f"Error: {str(e)}")
143
- else:
144
- col2.error("Por favor, proporciona el p煤blico objetivo y el producto.")
 
2
  import streamlit as st
3
  import os
4
  import google.generativeai as genai
5
+ import random # Nueva importaci贸n para la selecci贸n aleatoria de menci贸n
6
 
7
  load_dotenv()
8
 
 
19
 
20
  def get_gemini_response(target_audience, product, text_type, length, mood, model_choice):
21
  # Generar la menci贸n aleatoria
22
+ product_mention = get_random_product_mention() # Llamada correcta a la funci贸n
23
  model = genai.GenerativeModel(model_choice)
24
 
25
  # Crear la instrucci贸n de menci贸n basada en la opci贸n seleccionada
 
80
  raise ValueError("Lo sentimos, intenta con una combinaci贸n diferente de entradas.")
81
 
82
  # Inicializar la aplicaci贸n Streamlit
83
+ st.set_page_config(page_title="VisionTales", layout="wide")
84
+ st.title("VisionTales: Crea historias inolvidables con IA")
85
+
86
+ with st.sidebar:
87
+ st.header("Personaliza tu texto")
88
+ target_audience = st.text_input("驴Qui茅n es tu p煤blico objetivo?")
89
+ product = st.text_input("Nombre del producto:")
90
+ text_type = st.selectbox("Tipo de texto:", ["Historia", "Carta de venta", "Correo", "Landing page"])
91
+ length = st.slider("Longitud del texto:", 50, 1000, 300)
92
+ mood = st.selectbox("Estado de 谩nimo:", ["Feliz", "Triste", "Motivador", "Reflexivo"])
93
+ model_choice = st.selectbox("Selecciona el modelo:", ["gemini-1.5-flash", "gemini-1.5-pro"])
94
+
95
+ # Bot贸n para generar el texto
96
+ if st.button("Generar texto"):
97
+ try:
98
+ generated_text = get_gemini_response(target_audience, product, text_type, length, mood, model_choice)
99
+ st.subheader("Texto Generado:")
100
+ st.write(generated_text)
101
+ except Exception as e:
102
+ st.error(f"Error: {e}")
103
+
104
+ st.markdown("---")
105
+ st.write("Este generador de texto est谩 dise帽ado para ayudarte a crear contenido atractivo y efectivo con la ayuda de la inteligencia artificial.")