Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ from dotenv import load_dotenv
|
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
import google.generativeai as genai
|
5 |
-
import langchain
|
6 |
|
7 |
# Cargar las variables de entorno
|
8 |
load_dotenv()
|
@@ -14,14 +13,14 @@ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
|
14 |
def get_gemini_response_bullets(target_audience, product, num_bullets, temperature):
|
15 |
|
16 |
# Configuraci贸n del modelo generativo y las instrucciones del sistema
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
model = genai.GenerativeModel(
|
26 |
model_name="gemini-1.5-flash", # Nombre del modelo que estamos utilizando
|
27 |
generation_config=generation_config, # Configuraci贸n de generaci贸n
|
@@ -36,23 +35,23 @@ def get_gemini_response_bullets(target_audience, product, num_bullets, temperatu
|
|
36 |
)
|
37 |
)
|
38 |
|
39 |
-
bullets_instruction = (
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
)
|
44 |
|
45 |
-
# Generar el resultado utilizando el modelo con la instrucci贸n espec铆fica
|
46 |
-
try:
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
except Exception as e:
|
55 |
-
|
56 |
|
57 |
# Inicializar la aplicaci贸n Streamlit
|
58 |
st.set_page_config(page_title="Generador de Bullets", layout="wide")
|
|
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
import google.generativeai as genai
|
|
|
5 |
|
6 |
# Cargar las variables de entorno
|
7 |
load_dotenv()
|
|
|
13 |
def get_gemini_response_bullets(target_audience, product, num_bullets, temperature):
|
14 |
|
15 |
# Configuraci贸n del modelo generativo y las instrucciones del sistema
|
16 |
+
generation_config = {
|
17 |
+
"temperature": temperature,
|
18 |
+
"top_p": 0.9, # Aumentar para permitir una mayor diversidad en las opciones generadas
|
19 |
+
"top_k": 90,
|
20 |
+
"max_output_tokens": 2048,
|
21 |
+
"response_mime_type": "text/plain",
|
22 |
+
}
|
23 |
+
|
24 |
model = genai.GenerativeModel(
|
25 |
model_name="gemini-1.5-flash", # Nombre del modelo que estamos utilizando
|
26 |
generation_config=generation_config, # Configuraci贸n de generaci贸n
|
|
|
35 |
)
|
36 |
)
|
37 |
|
38 |
+
bullets_instruction = (
|
39 |
+
f"Quiero que escribas {num_bullets} bullets que transmitan los beneficios de {product} de una manera que atraiga a {target_audience}. "
|
40 |
+
f"Conecta los problemas y deseos de {target_audience} de forma conversacional, no rob贸tico, ni utilices ':', con un estilo amigable y divertido. "
|
41 |
+
f"Por favor, genera bullets creativos que hagan que {target_audience} se sienta emocionado por {product}."
|
42 |
+
)
|
43 |
|
44 |
+
# Generar el resultado utilizando el modelo con la instrucci贸n espec铆fica
|
45 |
+
try:
|
46 |
+
response = model.generate_content([bullets_instruction])
|
47 |
+
|
48 |
+
# Extraer el texto de la respuesta
|
49 |
+
generated_bullets = response.candidates[0].content.parts[0].text.strip()
|
50 |
+
|
51 |
+
# Retornar el resultado
|
52 |
+
return generated_bullets
|
53 |
+
except Exception as e:
|
54 |
+
raise ValueError(f"Error al generar los bullets: {str(e)}")
|
55 |
|
56 |
# Inicializar la aplicaci贸n Streamlit
|
57 |
st.set_page_config(page_title="Generador de Bullets", layout="wide")
|