Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,122 +1,43 @@
|
|
1 |
-
from dotenv import load_dotenv
|
2 |
-
import streamlit as st
|
3 |
import os
|
|
|
4 |
import google.generativeai as genai
|
5 |
-
from
|
6 |
-
from
|
7 |
-
from prompts import create_instruction
|
8 |
-
from angles import bullet_angles
|
9 |
|
10 |
-
# Cargar las variables de entorno
|
11 |
load_dotenv()
|
12 |
-
|
13 |
-
# Configurar la API de Google
|
14 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
"
|
|
|
21 |
}
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
number_of_benefits,
|
32 |
-
target_audience,
|
33 |
-
product,
|
34 |
-
selected_formula,
|
35 |
-
selected_angle
|
36 |
)
|
37 |
-
|
38 |
-
response = model.generate_content([benefits_instruction], generation_config={"temperature": temperature})
|
39 |
-
return response.parts[0].text if response and response.parts else "Error generating content."
|
40 |
-
|
41 |
-
# Configurar la interfaz de usuario con Streamlit
|
42 |
-
st.set_page_config(page_title="Bullet Benefits Generator", layout="wide")
|
43 |
-
|
44 |
-
# Leer el contenido del archivo manual.md
|
45 |
-
with open("manual.md", "r", encoding="utf-8") as file:
|
46 |
-
manual_content = file.read()
|
47 |
-
|
48 |
-
# Mostrar el contenido del manual en el sidebar
|
49 |
-
st.sidebar.markdown(manual_content)
|
50 |
-
|
51 |
-
# Ocultar elementos de la interfaz
|
52 |
-
st.markdown(styles["main_layout"], unsafe_allow_html=True)
|
53 |
-
|
54 |
-
# Centrar el título y el subtítulo
|
55 |
-
st.markdown("<h1 style='text-align: center;'>Bullet Benefits Generator</h1>", unsafe_allow_html=True)
|
56 |
-
st.markdown("<h4 style='text-align: center;'>Transforma características en beneficios irresistibles que conectan emocionalmente con tu audiencia.</h4>", unsafe_allow_html=True)
|
57 |
-
|
58 |
-
# Añadir CSS personalizado para el botón
|
59 |
-
st.markdown(styles["button"], unsafe_allow_html=True)
|
60 |
-
|
61 |
-
# Crear columnas
|
62 |
-
col1, col2 = st.columns([1, 2])
|
63 |
-
|
64 |
-
# Columnas de entrada
|
65 |
-
# Inside the column section
|
66 |
-
with col1:
|
67 |
-
target_audience = st.text_input("¿Quién es tu público objetivo?", placeholder="Ejemplo: Estudiantes Universitarios")
|
68 |
-
product = st.text_input("¿Qué producto tienes en mente?", placeholder="Ejemplo: Curso de Inglés")
|
69 |
-
number_of_benefits = st.selectbox("Número de Beneficios", options=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], index=4)
|
70 |
-
|
71 |
-
# Fix indentation - remove extra spaces
|
72 |
-
with st.expander("Opciones avanzadas"):
|
73 |
-
selected_formula_key = st.selectbox(
|
74 |
-
"Tipo de bullet", # Added label
|
75 |
-
options=list(bullet_formulas.keys()),
|
76 |
-
label_visibility="visible"
|
77 |
-
)
|
78 |
-
selected_formula = bullet_formulas[selected_formula_key]
|
79 |
-
|
80 |
-
selected_angle_key = st.selectbox(
|
81 |
-
"Ángulo del bullet", # Added label
|
82 |
-
options=list(bullet_angles.keys()),
|
83 |
-
label_visibility="visible"
|
84 |
-
)
|
85 |
-
selected_angle = bullet_angles[selected_angle_key]
|
86 |
-
|
87 |
-
temperature = st.slider(
|
88 |
-
"Nivel de creatividad", # Added label
|
89 |
-
min_value=0.0,
|
90 |
-
max_value=2.0,
|
91 |
-
value=1.0,
|
92 |
-
step=0.1,
|
93 |
-
label_visibility="visible"
|
94 |
-
)
|
95 |
-
|
96 |
-
submit = st.button("GENERAR LOS BULLETS POINTS")
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
else:
|
114 |
-
col2.markdown(f"""
|
115 |
-
<div style="{styles['results_container']}">
|
116 |
-
<h3>Beneficios Generados:</h3>
|
117 |
-
<p>{generated_benefits}</p>
|
118 |
-
</div>
|
119 |
-
""", unsafe_allow_html=True)
|
120 |
|
121 |
-
else:
|
122 |
-
col2.warning("Por favor, completa todos los campos antes de generar beneficios.")
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
import gradio as gr
|
3 |
import google.generativeai as genai
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
from prompts import system_prompt
|
|
|
|
|
6 |
|
|
|
7 |
load_dotenv()
|
|
|
|
|
8 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
9 |
|
10 |
+
model = genai.GenerativeModel(
|
11 |
+
model_name="gemini-2.0-flash",
|
12 |
+
generation_config={
|
13 |
+
"temperature": 0.9,
|
14 |
+
"top_p": 1,
|
15 |
+
"max_output_tokens": 2048,
|
16 |
}
|
17 |
+
)
|
18 |
+
|
19 |
+
def chat(message, history):
|
20 |
+
return (
|
21 |
+
f"{system_prompt}\n\n"
|
22 |
+
f"User Message: {message}\n"
|
23 |
+
f"Previous Context: {history if history else 'No previous context'}\n"
|
24 |
+
f"Remember to maintain the friendly and helpful tone of Chucho Bot, "
|
25 |
+
f"focusing only on CopyXpert course information and benefits."
|
|
|
|
|
|
|
|
|
|
|
26 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
demo = gr.ChatInterface(
|
29 |
+
fn=chat,
|
30 |
+
examples=[
|
31 |
+
"¿Qué incluye el curso CopyXpert?",
|
32 |
+
"¿Cuál es el precio del curso?",
|
33 |
+
"¿Cómo puedo inscribirme?",
|
34 |
+
"¿Qué beneficios obtendré?",
|
35 |
+
"¿Cuál es la metodología del curso?",
|
36 |
+
"¿Necesito experiencia previa?"
|
37 |
+
],
|
38 |
+
title="🤖Chucho Bot - CopyXpert Sales Assistant",
|
39 |
+
description="¡Hola! Soy Chucho Bot, tu asistente personal para el curso CopyXpert. ¿Cómo puedo ayudarte hoy?"
|
40 |
+
)
|
41 |
+
|
42 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
|
|
|