Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
import warnings
|
2 |
-
warnings.filterwarnings("ignore", category=FutureWarning, module="transformers.tokenization_utils_base")
|
3 |
-
|
4 |
-
import streamlit as st
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Load model and tokenizer
|
8 |
model_name = "EleutherAI/gpt-neo-1.3B" # Use a lightweight model
|
@@ -25,54 +26,61 @@ def generate_situations_and_copys(stage, product, situation):
|
|
25 |
"""
|
26 |
return generate_text(prompt)
|
27 |
|
28 |
-
#
|
29 |
-
def main():
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
"Middle": ["Elige el modelo de dispositivo POS", "Entrega express en Lima"],
|
41 |
-
"Lower": ["Servicios de cobro inmediato", "Cargas Ilimitadas de productos a Wix"]
|
42 |
-
}
|
43 |
-
product = st.selectbox("Producto", products[stage])
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
"No pudiste elegir el nombre que te pusieron, pero s铆 puedes elegir que tu tel茅fono sea tu POS."
|
51 |
-
],
|
52 |
-
"Middle": [
|
53 |
-
"No elegiste todas las decisiones dif铆ciles, pero s铆 puedes elegir la herramienta perfecta para cada transacci贸n.",
|
54 |
-
"No puedes elegir todas las circunstancias, pero s铆 el modelo de POS adecuado para tu negocio."
|
55 |
-
],
|
56 |
-
"Lower": [
|
57 |
-
"No elegiste que el cliente pagara tarde, pero s铆 c贸mo cobrar r谩pido.",
|
58 |
-
"No puedes elegir el ritmo de las ventas, pero s铆 c贸mo acelerar los cobros."
|
59 |
-
]
|
60 |
-
}
|
61 |
-
situation = st.selectbox("Situaci贸n", situations[stage])
|
62 |
|
63 |
-
|
64 |
-
if st.button("Generar Copys"):
|
65 |
-
st.header("4. Copys Generados")
|
66 |
-
generated_copys = generate_situations_and_copys(stage, product, situation)
|
67 |
-
st.write(generated_copys)
|
68 |
|
69 |
-
#
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
custom_copys = generate_text(custom_prompt)
|
74 |
-
st.write(custom_copys)
|
75 |
|
76 |
-
|
77 |
-
main()
|
78 |
|
|
|
|
1 |
import warnings
|
|
|
|
|
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
# Ignore specific warnings
|
6 |
+
warnings.filterwarnings("ignore", category=FutureWarning, module="transformers.tokenization_utils_base")
|
7 |
|
8 |
# Load model and tokenizer
|
9 |
model_name = "EleutherAI/gpt-neo-1.3B" # Use a lightweight model
|
|
|
26 |
"""
|
27 |
return generate_text(prompt)
|
28 |
|
29 |
+
# Gradio Interface
|
30 |
+
def main(stage, product, situation):
|
31 |
+
generated_copys = generate_situations_and_copys(stage, product, situation)
|
32 |
+
return generated_copys
|
33 |
+
|
34 |
+
# Dropdown options for Gradio
|
35 |
+
stages = ["Upper", "Middle", "Lower"]
|
36 |
+
products = {
|
37 |
+
"Upper": ["Convierte tu tel茅fono en un POS", "M谩s de 700 plantillas web con Wix"],
|
38 |
+
"Middle": ["Elige el modelo de dispositivo POS", "Entrega express en Lima"],
|
39 |
+
"Lower": ["Servicios de cobro inmediato", "Cargas Ilimitadas de productos a Wix"]
|
40 |
+
}
|
41 |
+
situations = {
|
42 |
+
"Upper": [
|
43 |
+
"No elegiste d贸nde naciste, pero s铆 c贸mo gestionar tus ventas.",
|
44 |
+
"No pudiste elegir el nombre que te pusieron, pero s铆 puedes elegir que tu tel茅fono sea tu POS."
|
45 |
+
],
|
46 |
+
"Middle": [
|
47 |
+
"No elegiste todas las decisiones dif铆ciles, pero s铆 puedes elegir la herramienta perfecta para cada transacci贸n.",
|
48 |
+
"No puedes elegir todas las circunstancias, pero s铆 el modelo de POS adecuado para tu negocio."
|
49 |
+
],
|
50 |
+
"Lower": [
|
51 |
+
"No elegiste que el cliente pagara tarde, pero s铆 c贸mo cobrar r谩pido.",
|
52 |
+
"No puedes elegir el ritmo de las ventas, pero s铆 c贸mo acelerar los cobros."
|
53 |
+
]
|
54 |
+
}
|
55 |
+
|
56 |
+
def update_products(stage):
|
57 |
+
return gr.Dropdown.update(choices=products[stage])
|
58 |
+
|
59 |
+
def update_situations(stage):
|
60 |
+
return gr.Dropdown.update(choices=situations[stage])
|
61 |
|
62 |
+
# Gradio App Interface
|
63 |
+
with gr.Blocks() as demo:
|
64 |
+
gr.Markdown("# Herramienta de Generaci贸n de Copys Publicitarios")
|
65 |
|
66 |
+
with gr.Row():
|
67 |
+
stage_input = gr.Dropdown(choices=stages, label="Etapa del Funnel", interactive=True)
|
68 |
+
product_input = gr.Dropdown(choices=[], label="Producto", interactive=True)
|
69 |
+
situation_input = gr.Dropdown(choices=[], label="Situaci贸n", interactive=True)
|
|
|
|
|
|
|
|
|
70 |
|
71 |
+
stage_input.change(fn=update_products, inputs=stage_input, outputs=product_input)
|
72 |
+
stage_input.change(fn=update_situations, inputs=stage_input, outputs=situation_input)
|
73 |
+
|
74 |
+
generate_button = gr.Button("Generar Copys")
|
75 |
+
output_text = gr.Textbox(label="Copys Generados")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
+
generate_button.click(main, inputs=[stage_input, product_input, situation_input], outputs=output_text)
|
|
|
|
|
|
|
|
|
78 |
|
79 |
+
# Optional Custom Prompt Section
|
80 |
+
custom_prompt_input = gr.Textbox(label="Ingresa un prompt para personalizar el copy", value="")
|
81 |
+
generate_custom_button = gr.Button("Generar Copys Personalizados")
|
82 |
+
custom_output_text = gr.Textbox(label="Copys Personalizados")
|
|
|
|
|
83 |
|
84 |
+
generate_custom_button.click(fn=generate_text, inputs=custom_prompt_input, outputs=custom_output_text)
|
|
|
85 |
|
86 |
+
demo.launch()
|