Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,12 +12,12 @@ if not api_key:
|
|
12 |
# Configura el cliente de la API de Claude (Anthropic)
|
13 |
client = anthropic.Anthropic(api_key=api_key)
|
14 |
|
15 |
-
def generate_headlines(number_of_headlines, target_audience, product):
|
16 |
# Llama a la API de Claude para generar titulares
|
17 |
message = client.messages.create(
|
18 |
model="claude-3-5-sonnet-20240620",
|
19 |
-
max_tokens=
|
20 |
-
temperature=
|
21 |
system="You are a world-class copywriter, with experience in creating hooks, headlines, and subject lines that immediately capture attention. Your skill lies in deeply understanding the emotions, desires, and challenges of a specific audience, allowing you to design personalized marketing strategies that resonate and motivate action. You know how to use proven structures to attract your target audience, generating interest and achieving a powerful connection that drives desired results in advertising and content campaigns.\n\nAnswer in Spanish.",
|
22 |
messages=[
|
23 |
{
|
@@ -34,8 +34,8 @@ def generate_headlines(number_of_headlines, target_audience, product):
|
|
34 |
return message.content
|
35 |
|
36 |
# Configura la interfaz de usuario con Gradio
|
37 |
-
def gradio_generate_headlines(number_of_headlines, target_audience, product):
|
38 |
-
return generate_headlines(number_of_headlines, target_audience, product)
|
39 |
|
40 |
# Define los colores de la interfaz según el logo de Anthropic (ejemplo)
|
41 |
logo_colors = {
|
@@ -44,26 +44,10 @@ logo_colors = {
|
|
44 |
"text_color": "#212529"
|
45 |
}
|
46 |
|
47 |
-
# Configura la interfaz de usuario
|
48 |
with gr.Blocks(css=f"""
|
49 |
-
.gradio-container {{
|
50 |
-
|
51 |
-
}}
|
52 |
-
.gradio-button {{
|
53 |
-
margin-top: 10px;
|
54 |
-
background-color: {logo_colors["primary"]};
|
55 |
-
color: white;
|
56 |
-
border: none;
|
57 |
-
border-radius: 4px;
|
58 |
-
padding: 10px;
|
59 |
-
}}
|
60 |
-
.gradio-button:hover {{
|
61 |
-
background-color: #1b5bb5;
|
62 |
-
}}
|
63 |
-
.result-text {{
|
64 |
-
white-space: pre-line;
|
65 |
-
text-align: left;
|
66 |
-
}}
|
67 |
""") as demo:
|
68 |
gr.Markdown(
|
69 |
f"""
|
@@ -73,19 +57,30 @@ with gr.Blocks(css=f"""
|
|
73 |
)
|
74 |
|
75 |
with gr.Row():
|
76 |
-
with gr.Column(scale=
|
77 |
-
number_of_headlines = gr.
|
|
|
|
|
|
|
|
|
78 |
target_audience = gr.Textbox(label="Público Objetivo", placeholder="Ejemplo: Estudiantes Universitarios")
|
79 |
product = gr.Textbox(label="Producto", placeholder="Ejemplo: Curso de Inglés")
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
with gr.Column(scale=1):
|
82 |
-
submit_btn = gr.Button("Generar Titulares")
|
83 |
|
84 |
-
output = gr.Textbox(label="Titulares Generados", lines=10,
|
85 |
|
86 |
submit_btn.click(
|
87 |
fn=gradio_generate_headlines,
|
88 |
-
inputs=[number_of_headlines, target_audience, product],
|
89 |
outputs=output
|
90 |
)
|
91 |
|
|
|
12 |
# Configura el cliente de la API de Claude (Anthropic)
|
13 |
client = anthropic.Anthropic(api_key=api_key)
|
14 |
|
15 |
+
def generate_headlines(number_of_headlines, target_audience, product, temperature):
|
16 |
# Llama a la API de Claude para generar titulares
|
17 |
message = client.messages.create(
|
18 |
model="claude-3-5-sonnet-20240620",
|
19 |
+
max_tokens=2500,
|
20 |
+
temperature=temperature,
|
21 |
system="You are a world-class copywriter, with experience in creating hooks, headlines, and subject lines that immediately capture attention. Your skill lies in deeply understanding the emotions, desires, and challenges of a specific audience, allowing you to design personalized marketing strategies that resonate and motivate action. You know how to use proven structures to attract your target audience, generating interest and achieving a powerful connection that drives desired results in advertising and content campaigns.\n\nAnswer in Spanish.",
|
22 |
messages=[
|
23 |
{
|
|
|
34 |
return message.content
|
35 |
|
36 |
# Configura la interfaz de usuario con Gradio
|
37 |
+
def gradio_generate_headlines(number_of_headlines, target_audience, product, temperature):
|
38 |
+
return generate_headlines(number_of_headlines, target_audience, product, temperature)
|
39 |
|
40 |
# Define los colores de la interfaz según el logo de Anthropic (ejemplo)
|
41 |
logo_colors = {
|
|
|
44 |
"text_color": "#212529"
|
45 |
}
|
46 |
|
|
|
47 |
with gr.Blocks(css=f"""
|
48 |
+
.gradio-container {{ background-color: {logo_colors["background"]}; }}
|
49 |
+
.headline-output {{ text-align: left; white-space: pre-line; }}
|
50 |
+
.gradio-slider .slider-container {{ margin: 20px 0; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
""") as demo:
|
52 |
gr.Markdown(
|
53 |
f"""
|
|
|
57 |
)
|
58 |
|
59 |
with gr.Row():
|
60 |
+
with gr.Column(scale=1):
|
61 |
+
number_of_headlines = gr.Dropdown(
|
62 |
+
label="Número de Titulares",
|
63 |
+
choices=[i for i in range(1, 11)],
|
64 |
+
value=5
|
65 |
+
)
|
66 |
target_audience = gr.Textbox(label="Público Objetivo", placeholder="Ejemplo: Estudiantes Universitarios")
|
67 |
product = gr.Textbox(label="Producto", placeholder="Ejemplo: Curso de Inglés")
|
68 |
+
temperature = gr.Slider(
|
69 |
+
minimum=0,
|
70 |
+
maximum=1,
|
71 |
+
value=0,
|
72 |
+
step=0.1,
|
73 |
+
label="Temperature",
|
74 |
+
interactive=True
|
75 |
+
)
|
76 |
with gr.Column(scale=1):
|
77 |
+
submit_btn = gr.Button("Generar Titulares", elem_id="submit-btn")
|
78 |
|
79 |
+
output = gr.Textbox(label="Titulares Generados", lines=10, css_class="headline-output")
|
80 |
|
81 |
submit_btn.click(
|
82 |
fn=gradio_generate_headlines,
|
83 |
+
inputs=[number_of_headlines, target_audience, product, temperature],
|
84 |
outputs=output
|
85 |
)
|
86 |
|