Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,13 +8,13 @@ load_dotenv()
|
|
8 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
9 |
|
10 |
# Función para obtener respuesta del modelo Gemini
|
11 |
-
def get_gemini_response(
|
12 |
model = genai.GenerativeModel(model_choice)
|
13 |
|
14 |
-
# Crear el prompt completo
|
15 |
full_prompt = f"""
|
16 |
-
Eres un escritor creativo famoso. Crea un {length} {
|
17 |
-
El {
|
18 |
Asegúrate de que contenga elementos realistas y emocionales.
|
19 |
"""
|
20 |
|
@@ -63,9 +63,9 @@ with col1:
|
|
63 |
# Entradas del usuario
|
64 |
target_audience = st.text_input("Público objetivo:", placeholder="Especifica tu público aquí...")
|
65 |
product = st.text_input("Producto:", placeholder="Especifica el producto aquí...")
|
66 |
-
|
67 |
length = st.selectbox("Longitud del texto:", ["Corto", "Largo"])
|
68 |
-
language = st.selectbox("Idioma del texto:", ["
|
69 |
mood = st.selectbox("Estado de ánimo:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Romántico"])
|
70 |
|
71 |
# Opción para seleccionar el modelo
|
@@ -78,7 +78,7 @@ with col1:
|
|
78 |
if submit:
|
79 |
if target_audience and product: # Verificar que se haya proporcionado el público objetivo y el producto
|
80 |
try:
|
81 |
-
response = get_gemini_response(target_audience, product,
|
82 |
col2.subheader("Contenido generado:")
|
83 |
col2.write(response)
|
84 |
except ValueError as e:
|
|
|
8 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
9 |
|
10 |
# Función para obtener respuesta del modelo Gemini
|
11 |
+
def get_gemini_response(target_audience, product, text_type, length, language, mood, model_choice):
|
12 |
model = genai.GenerativeModel(model_choice)
|
13 |
|
14 |
+
# Crear el prompt completo basado en los campos del frontend
|
15 |
full_prompt = f"""
|
16 |
+
Eres un escritor creativo famoso. Crea un {length} {text_type} en {language}.
|
17 |
+
El {text_type} debe ser {mood}, dirigido a este público objetivo: {target_audience}, y relacionado con el producto: "{product}".
|
18 |
Asegúrate de que contenga elementos realistas y emocionales.
|
19 |
"""
|
20 |
|
|
|
63 |
# Entradas del usuario
|
64 |
target_audience = st.text_input("Público objetivo:", placeholder="Especifica tu público aquí...")
|
65 |
product = st.text_input("Producto:", placeholder="Especifica el producto aquí...")
|
66 |
+
text_type = st.selectbox("Tipo de texto:", ["Story", "Shayari", "Sher", "Poem", "Quote"])
|
67 |
length = st.selectbox("Longitud del texto:", ["Corto", "Largo"])
|
68 |
+
language = st.selectbox("Idioma del texto:", ["Español", "Inglés"])
|
69 |
mood = st.selectbox("Estado de ánimo:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Romántico"])
|
70 |
|
71 |
# Opción para seleccionar el modelo
|
|
|
78 |
if submit:
|
79 |
if target_audience and product: # Verificar que se haya proporcionado el público objetivo y el producto
|
80 |
try:
|
81 |
+
response = get_gemini_response(target_audience, product, text_type, length, language, mood, model_choice)
|
82 |
col2.subheader("Contenido generado:")
|
83 |
col2.write(response)
|
84 |
except ValueError as e:
|