Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
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 =
|
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="
|
84 |
-
|
85 |
-
|
86 |
-
st.
|
87 |
-
st.
|
88 |
-
|
89 |
-
|
90 |
-
st.
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
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.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|