Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,15 +10,11 @@ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
|
10 |
|
11 |
# Funci贸n para obtener una menci贸n del producto de manera probabil铆stica
|
12 |
def get_random_product_mention():
|
13 |
-
# Definir las opciones de menci贸n y sus probabilidades
|
14 |
mentions = ["Directa", "Indirecta", "Metaf贸rica"]
|
15 |
-
probabilities = [0.34, 0.33, 0.33] # Probabilidades de cada menci贸n
|
16 |
-
|
17 |
-
# Elegir una opci贸n al azar bas谩ndose en las probabilidades
|
18 |
return random.choices(mentions, probabilities)[0]
|
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 |
|
@@ -93,12 +89,12 @@ with st.sidebar:
|
|
93 |
mood = st.selectbox("Tono de voz", ["Conversacional", "Formal", "Emocional", "Persuasivo"])
|
94 |
model_choice = st.selectbox("Modelo", ["gemini-1.5-flash", "gemini-1.5-pro"])
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
10 |
|
11 |
# Funci贸n para obtener una menci贸n del producto de manera probabil铆stica
|
12 |
def get_random_product_mention():
|
|
|
13 |
mentions = ["Directa", "Indirecta", "Metaf贸rica"]
|
14 |
+
probabilities = [0.34, 0.33, 0.33] # Probabilidades de cada menci贸n
|
|
|
|
|
15 |
return random.choices(mentions, probabilities)[0]
|
16 |
|
17 |
def get_gemini_response(target_audience, product, text_type, length, mood, model_choice):
|
|
|
18 |
product_mention = get_random_product_mention() # Llamada correcta a la funci贸n
|
19 |
model = genai.GenerativeModel(model_choice)
|
20 |
|
|
|
89 |
mood = st.selectbox("Tono de voz", ["Conversacional", "Formal", "Emocional", "Persuasivo"])
|
90 |
model_choice = st.selectbox("Modelo", ["gemini-1.5-flash", "gemini-1.5-pro"])
|
91 |
|
92 |
+
# Bot贸n para generar el texto (fuera de la barra lateral)
|
93 |
+
if st.button("Escribir mi texto"):
|
94 |
+
try:
|
95 |
+
# Obtener la respuesta del modelo
|
96 |
+
generated_text = get_gemini_response(target_audience, product, text_type, length, mood, model_choice)
|
97 |
+
st.write("**Texto generado:**")
|
98 |
+
st.write(generated_text)
|
99 |
+
except Exception as e:
|
100 |
+
st.error(f"Ocurri贸 un error: {e}")
|