Update app.py
Browse files
app.py
CHANGED
|
@@ -16,8 +16,8 @@ def generate_headlines(number_of_headlines, target_audience, product, temperatur
|
|
| 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=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 |
{
|
|
@@ -37,47 +37,31 @@ def generate_headlines(number_of_headlines, target_audience, product, temperatur
|
|
| 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 |
-
|
| 41 |
-
logo_colors = {
|
| 42 |
-
"background": "#f8f8f8",
|
| 43 |
-
"primary": "#2c7be5",
|
| 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 |
-
.gradio-column {{ margin: 20px; }}
|
| 52 |
-
""") as demo:
|
| 53 |
gr.Markdown(
|
| 54 |
-
|
| 55 |
-
<h1 style="color:
|
| 56 |
-
<p style="color:
|
| 57 |
"""
|
| 58 |
)
|
| 59 |
-
|
| 60 |
with gr.Row():
|
| 61 |
-
with gr.Column(
|
| 62 |
-
number_of_headlines = gr.Dropdown(
|
| 63 |
-
label="Número de Titulares",
|
| 64 |
-
choices=[i for i in range(1, 11)],
|
| 65 |
-
value=5
|
| 66 |
-
)
|
| 67 |
target_audience = gr.Textbox(label="Público Objetivo", placeholder="Ejemplo: Estudiantes Universitarios")
|
| 68 |
product = gr.Textbox(label="Producto", placeholder="Ejemplo: Curso de Inglés")
|
| 69 |
-
temperature = gr.Slider(
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
)
|
| 77 |
-
with gr.Column(scale=1):
|
| 78 |
-
submit_btn = gr.Button("Generar Titulares", elem_id="submit-btn")
|
| 79 |
-
|
| 80 |
-
output = gr.Textbox(label="Titulares Generados", lines=10)
|
| 81 |
|
| 82 |
submit_btn.click(
|
| 83 |
fn=gradio_generate_headlines,
|
|
|
|
| 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=4000, # Cambiado a 4000 tokens
|
| 20 |
+
temperature=temperature, # Usa el valor del slider aquí
|
| 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 |
{
|
|
|
|
| 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 |
+
with gr.Blocks(css=".gradio-container { background-color: #f8f8f8; }") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
gr.Markdown(
|
| 42 |
+
"""
|
| 43 |
+
<h1 style="color: #2c7be5; text-align: center;">Generador de Titulares</h1>
|
| 44 |
+
<p style="color: #212529; text-align: center;">Usa el poder de Claude AI para crear titulares atractivos</p>
|
| 45 |
"""
|
| 46 |
)
|
| 47 |
+
|
| 48 |
with gr.Row():
|
| 49 |
+
with gr.Column():
|
| 50 |
+
number_of_headlines = gr.Dropdown(choices=[str(i) for i in range(1, 11)], label="Número de Titulares", value="5")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
target_audience = gr.Textbox(label="Público Objetivo", placeholder="Ejemplo: Estudiantes Universitarios")
|
| 52 |
product = gr.Textbox(label="Producto", placeholder="Ejemplo: Curso de Inglés")
|
| 53 |
+
temperature = gr.Slider(minimum=0, maximum=1, value=0, step=0.1, label="Creatividad")
|
| 54 |
+
submit_btn = gr.Button("Generar Titulares")
|
| 55 |
+
|
| 56 |
+
with gr.Column(scale=2):
|
| 57 |
+
output = gr.HTML(
|
| 58 |
+
"""
|
| 59 |
+
<div id="result-container" style="background-color: #ffffff; padding: 10px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
|
| 60 |
+
<p id="result-text" style="font-size: 16px; color: #333333;">Los titulares aparecerán aquí...</p>
|
| 61 |
+
</div>
|
| 62 |
+
""",
|
| 63 |
+
label="Titulares Generados"
|
| 64 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
submit_btn.click(
|
| 67 |
fn=gradio_generate_headlines,
|