JeCabrera commited on
Commit
dc809d3
verified
1 Parent(s): fd2b987

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -8,8 +8,8 @@ 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(target_audience, product, product_mention, mood, model_choice):
12
- model = genai.GenerativeModel(model_choice)
13
 
14
  # Crear la instrucci贸n de menci贸n basada en la opci贸n seleccionada
15
  mention_instruction = ""
@@ -23,9 +23,6 @@ def get_gemini_response(target_audience, product, product_mention, mood, model_c
23
  # Instrucci贸n espec铆fica para el tipo de texto (siempre ser谩 "Historia")
24
  format_instruction = "Ensure that the narrative is engaging and includes character development, a clear plot, and a resolution."
25
 
26
- # Longitud del texto (siempre ser谩 "Corto")
27
- length = "200 words"
28
-
29
  # Crear el prompt completo basado en los campos del frontend
30
  full_prompt = f"""
31
  You are a creative writer skilled in the art of persuasion. Write a {length} Historia in Spanish. The tone of the Historia should be {mood} and carefully crafted to emotionally resonate with a {target_audience}. {mention_instruction} {format_instruction} Use persuasive techniques to guide the reader towards an intuitive understanding of the product's benefits, focusing on creating a strong emotional connection with the audience.
@@ -84,9 +81,9 @@ with col1:
84
 
85
  # Eliminar la opci贸n de tipo de texto y longitud del texto
86
  mood = st.selectbox("Tono del Texto:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Rom谩ntico"])
87
-
88
- # Opci贸n para seleccionar el modelo
89
- model_choice = st.selectbox("Selecciona el modelo:", ["gemini-1.5-flash", "gemini-1.5-pro"], index=0)
90
 
91
  # Bot贸n para generar contenido
92
  submit = st.button("Escribir mi historia")
@@ -95,7 +92,7 @@ with col1:
95
  if submit:
96
  if target_audience and product: # Verificar que se haya proporcionado el p煤blico objetivo y el producto
97
  try:
98
- response = get_gemini_response(target_audience, product, product_mention, mood, model_choice)
99
  col2.subheader("Contenido generado:")
100
  col2.write(response)
101
  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, product_mention, mood, length):
12
+ model = genai.GenerativeModel("gemini-1.5-flash") # Modelo predeterminado
13
 
14
  # Crear la instrucci贸n de menci贸n basada en la opci贸n seleccionada
15
  mention_instruction = ""
 
23
  # Instrucci贸n espec铆fica para el tipo de texto (siempre ser谩 "Historia")
24
  format_instruction = "Ensure that the narrative is engaging and includes character development, a clear plot, and a resolution."
25
 
 
 
 
26
  # Crear el prompt completo basado en los campos del frontend
27
  full_prompt = f"""
28
  You are a creative writer skilled in the art of persuasion. Write a {length} Historia in Spanish. The tone of the Historia should be {mood} and carefully crafted to emotionally resonate with a {target_audience}. {mention_instruction} {format_instruction} Use persuasive techniques to guide the reader towards an intuitive understanding of the product's benefits, focusing on creating a strong emotional connection with the audience.
 
81
 
82
  # Eliminar la opci贸n de tipo de texto y longitud del texto
83
  mood = st.selectbox("Tono del Texto:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Rom谩ntico"])
84
+
85
+ # Slider para seleccionar la longitud del texto
86
+ length = st.slider("Longitud del texto (palabras):", min_value=100, max_value=300, value=200, step=50)
87
 
88
  # Bot贸n para generar contenido
89
  submit = st.button("Escribir mi historia")
 
92
  if submit:
93
  if target_audience and product: # Verificar que se haya proporcionado el p煤blico objetivo y el producto
94
  try:
95
+ response = get_gemini_response(target_audience, product, product_mention, mood, length)
96
  col2.subheader("Contenido generado:")
97
  col2.write(response)
98
  except ValueError as e: