Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,83 +1,64 @@
|
|
1 |
-
|
2 |
-
import
|
3 |
-
import
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
|
8 |
-
def
|
9 |
-
#
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
f"* ex. \"Here's how I tell my stories. All you need are these 3: ACT I, ACT II, and ACT III.\"\n"
|
27 |
-
f"* She proceeds to explain how we structure and tell our stories, which answers and resolves the initial conflict\n"
|
28 |
-
f"A call to action or loop.\n"
|
29 |
-
f"Call-To-Action\n"
|
30 |
-
f"* After giving valuable information to your viewer, you have to be able to lead them somewhere or encourage them to engage\n"
|
31 |
-
f"* ex. \"And if you wanna know how that looks like, then watch this video back and follow for more.\"\n"
|
32 |
-
f"* This encourages the audience to rewatch the video to see the video is an actual example of what they just learned and it encourages them to follow and share the content if they found it valuable!\n"
|
33 |
-
f"Follow viral video recipe above in creating a Viral Video script for me. Do not repeat the instructions above, just use the framework for the viral video script. Every output must include: HOOK, THE SETUP, THE CONFLICT, THE RESOLUTION, THE CTA. \n"
|
34 |
-
f"Topic: {title}\n"
|
35 |
-
f"Tone: {emotional_tone}\n"
|
36 |
-
f"Formality Level: {formality_level}\n"
|
37 |
-
f"Engagement Level: {engagement_level}"
|
38 |
)
|
|
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
messages=[
|
44 |
-
{"role": "system", "content": "Generate a script based on the following instructions."},
|
45 |
-
{"role": "user", "content": prompt}
|
46 |
-
],
|
47 |
-
temperature=0.7,
|
48 |
-
max_tokens=1024,
|
49 |
-
)
|
50 |
-
# Accessing the generated script from the response
|
51 |
-
script = response['choices'][0]['message']['content'].strip()
|
52 |
-
return script
|
53 |
-
except Exception as e:
|
54 |
-
st.error(f"Failed to generate script: {str(e)}")
|
55 |
-
return "Error in generating script."
|
56 |
|
57 |
-
#
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
74 |
|
75 |
-
|
|
|
|
|
|
|
|
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
st.error("Please enter the title of the video.")
|
80 |
-
else:
|
81 |
-
video_script = generate_video_script(video_title, formality_level, emotional_tone, engagement_level)
|
82 |
-
with col2:
|
83 |
-
st.write(video_script)
|
|
|
1 |
+
# app.py
|
2 |
+
import gradio as gr
|
3 |
+
import anthropic
|
4 |
|
5 |
+
# Configura el cliente de la API de Claude (Anthropic)
|
6 |
+
client = anthropic.Anthropic(api_key="my_api_key") # Reemplaza "my_api_key" con tu clave de API
|
7 |
|
8 |
+
def generate_headlines(number_of_headlines, target_audience, product):
|
9 |
+
# Llama a la API de Claude para generar titulares
|
10 |
+
message = client.messages.create(
|
11 |
+
model="claude-3-5-sonnet-20240620",
|
12 |
+
max_tokens=1000,
|
13 |
+
temperature=0,
|
14 |
+
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.",
|
15 |
+
messages=[
|
16 |
+
{
|
17 |
+
"role": "user",
|
18 |
+
"content": [
|
19 |
+
{
|
20 |
+
"type": "text",
|
21 |
+
"text": f"Generate {number_of_headlines} attention-grabbing headlines designed for {target_audience} to generate interest in {product}. Each headline should be crafted to encourage a specific action, such as making a purchase, signing up, or downloading. Use a variety of formats (questions, bold statements, intriguing facts) to test different approaches."
|
22 |
+
}
|
23 |
+
]
|
24 |
+
}
|
25 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
)
|
27 |
+
return message.content
|
28 |
|
29 |
+
# Configura la interfaz de usuario con Gradio
|
30 |
+
def gradio_generate_headlines(number_of_headlines, target_audience, product):
|
31 |
+
return generate_headlines(number_of_headlines, target_audience, product)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
# Define los colores de la interfaz según el logo de Anthropic (ejemplo)
|
34 |
+
logo_colors = {
|
35 |
+
"background": "#f8f8f8",
|
36 |
+
"primary": "#2c7be5",
|
37 |
+
"text_color": "#212529"
|
38 |
+
}
|
39 |
|
40 |
+
with gr.Blocks(css=".gradio-container { background-color: " + logo_colors["background"] + "; }") as demo:
|
41 |
+
gr.Markdown(
|
42 |
+
f"""
|
43 |
+
<h1 style="color: {logo_colors['primary']}; text-align: center;">Generador de Titulares</h1>
|
44 |
+
<p style="color: {logo_colors['text_color']}; 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.Number(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 |
+
submit_btn = gr.Button("Generar Titulares", elem_id="submit-btn")
|
54 |
+
|
55 |
+
output = gr.Textbox(label="Titulares Generados", lines=10)
|
56 |
|
57 |
+
submit_btn.click(
|
58 |
+
fn=gradio_generate_headlines,
|
59 |
+
inputs=[number_of_headlines, target_audience, product],
|
60 |
+
outputs=output
|
61 |
+
)
|
62 |
|
63 |
+
# Lanza la interfaz
|
64 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|