Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,14 +2,14 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
API_KEY = os.getenv("
|
| 6 |
API_URL = "https://api.groq.com/openai/v1/chat/completions"
|
| 7 |
|
| 8 |
|
| 9 |
-
def
|
| 10 |
|
| 11 |
prompt = f"""
|
| 12 |
-
Write a
|
| 13 |
|
| 14 |
Topic: {topic}
|
| 15 |
Tone: {tone}
|
|
@@ -17,11 +17,11 @@ def generate_linkedin_post(topic, tone, audience, length):
|
|
| 17 |
Length: {length}
|
| 18 |
|
| 19 |
REQUIREMENTS:
|
| 20 |
-
-
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
"""
|
| 26 |
|
| 27 |
headers = {
|
|
@@ -42,51 +42,84 @@ def generate_linkedin_post(topic, tone, audience, length):
|
|
| 42 |
return res.text
|
| 43 |
|
| 44 |
|
| 45 |
-
# π¨ MODERN UI
|
| 46 |
css = """
|
| 47 |
body {
|
| 48 |
-
background: linear-gradient(135deg, #
|
|
|
|
| 49 |
}
|
| 50 |
|
|
|
|
| 51 |
.gradio-container {
|
| 52 |
max-width: 900px !important;
|
| 53 |
margin: auto !important;
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
background: white !important;
|
| 59 |
-
|
| 60 |
-
border: 1px solid #dbeafe !important;
|
| 61 |
}
|
| 62 |
|
|
|
|
| 63 |
button {
|
| 64 |
-
background: #2563eb !important;
|
| 65 |
color: white !important;
|
| 66 |
-
border-radius:
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
}
|
| 69 |
"""
|
| 70 |
|
|
|
|
| 71 |
with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
| 72 |
|
| 73 |
gr.Markdown("""
|
| 74 |
# π AI LinkedIn Post Generator
|
| 75 |
-
### Create viral LinkedIn posts with AI
|
| 76 |
""")
|
| 77 |
|
| 78 |
with gr.Row():
|
| 79 |
-
topic = gr.Textbox(label="π‘ Topic")
|
| 80 |
tone = gr.Dropdown(
|
| 81 |
-
["Professional", "Motivational", "
|
| 82 |
label="π― Tone"
|
| 83 |
)
|
| 84 |
|
| 85 |
with gr.Row():
|
| 86 |
-
audience = gr.Textbox(label="π₯
|
| 87 |
length = gr.Dropdown(["Short", "Medium", "Long"], label="π Length")
|
| 88 |
|
| 89 |
-
btn = gr.Button("β¨ Generate
|
| 90 |
|
| 91 |
output = gr.Textbox(
|
| 92 |
label="π’ Generated LinkedIn Post",
|
|
@@ -94,7 +127,7 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
| 94 |
)
|
| 95 |
|
| 96 |
btn.click(
|
| 97 |
-
|
| 98 |
inputs=[topic, tone, audience, length],
|
| 99 |
outputs=output
|
| 100 |
)
|
|
|
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
API_KEY = os.getenv("GROQ_API_KEY")
|
| 6 |
API_URL = "https://api.groq.com/openai/v1/chat/completions"
|
| 7 |
|
| 8 |
|
| 9 |
+
def generate_post(topic, tone, audience, length):
|
| 10 |
|
| 11 |
prompt = f"""
|
| 12 |
+
Write a powerful LinkedIn post.
|
| 13 |
|
| 14 |
Topic: {topic}
|
| 15 |
Tone: {tone}
|
|
|
|
| 17 |
Length: {length}
|
| 18 |
|
| 19 |
REQUIREMENTS:
|
| 20 |
+
- Strong hook π₯
|
| 21 |
+
- Human storytelling
|
| 22 |
+
- Natural emojis πππ‘
|
| 23 |
+
- Professional LinkedIn style
|
| 24 |
+
- 5β8 hashtags at end
|
| 25 |
"""
|
| 26 |
|
| 27 |
headers = {
|
|
|
|
| 42 |
return res.text
|
| 43 |
|
| 44 |
|
| 45 |
+
# π¨ MODERN UI (FIXED VISIBILITY + SPACING)
|
| 46 |
css = """
|
| 47 |
body {
|
| 48 |
+
background: linear-gradient(135deg, #eef2ff, #f8fafc);
|
| 49 |
+
color: #0f172a !important;
|
| 50 |
}
|
| 51 |
|
| 52 |
+
/* Container */
|
| 53 |
.gradio-container {
|
| 54 |
max-width: 900px !important;
|
| 55 |
margin: auto !important;
|
| 56 |
+
padding: 25px !important;
|
| 57 |
}
|
| 58 |
|
| 59 |
+
/* Headings */
|
| 60 |
+
h1, h2, h3, p {
|
| 61 |
+
color: #0f172a !important;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/* Inputs */
|
| 65 |
+
input, textarea, select {
|
| 66 |
+
border-radius: 10px !important;
|
| 67 |
+
border: 1px solid #cbd5e1 !important;
|
| 68 |
+
padding: 12px !important;
|
| 69 |
+
font-size: 15px !important;
|
| 70 |
background: white !important;
|
| 71 |
+
color: #0f172a !important;
|
|
|
|
| 72 |
}
|
| 73 |
|
| 74 |
+
/* Buttons */
|
| 75 |
button {
|
| 76 |
+
background: linear-gradient(90deg, #2563eb, #3b82f6) !important;
|
| 77 |
color: white !important;
|
| 78 |
+
border-radius: 12px !important;
|
| 79 |
+
padding: 12px 18px !important;
|
| 80 |
+
font-weight: 600 !important;
|
| 81 |
+
border: none !important;
|
| 82 |
+
transition: 0.2s ease-in-out;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
button:hover {
|
| 86 |
+
transform: scale(1.02);
|
| 87 |
+
opacity: 0.95;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/* Output box */
|
| 91 |
+
textarea {
|
| 92 |
+
min-height: 420px !important;
|
| 93 |
+
background: white !important;
|
| 94 |
+
border-radius: 14px !important;
|
| 95 |
+
border: 1px solid #e2e8f0 !important;
|
| 96 |
+
color: #0f172a !important;
|
| 97 |
+
padding: 15px !important;
|
| 98 |
+
font-size: 15px !important;
|
| 99 |
+
line-height: 1.6 !important;
|
| 100 |
}
|
| 101 |
"""
|
| 102 |
|
| 103 |
+
|
| 104 |
with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
| 105 |
|
| 106 |
gr.Markdown("""
|
| 107 |
# π AI LinkedIn Post Generator
|
| 108 |
+
### Create viral LinkedIn posts with AI β¨
|
| 109 |
""")
|
| 110 |
|
| 111 |
with gr.Row():
|
| 112 |
+
topic = gr.Textbox(label="π‘ Topic", placeholder="e.g. AI in 2026")
|
| 113 |
tone = gr.Dropdown(
|
| 114 |
+
["Professional", "Motivational", "Storytelling", "Casual"],
|
| 115 |
label="π― Tone"
|
| 116 |
)
|
| 117 |
|
| 118 |
with gr.Row():
|
| 119 |
+
audience = gr.Textbox(label="π₯ Audience", placeholder="e.g. Developers, Recruiters")
|
| 120 |
length = gr.Dropdown(["Short", "Medium", "Long"], label="π Length")
|
| 121 |
|
| 122 |
+
btn = gr.Button("β¨ Generate Post")
|
| 123 |
|
| 124 |
output = gr.Textbox(
|
| 125 |
label="π’ Generated LinkedIn Post",
|
|
|
|
| 127 |
)
|
| 128 |
|
| 129 |
btn.click(
|
| 130 |
+
generate_post,
|
| 131 |
inputs=[topic, tone, audience, length],
|
| 132 |
outputs=output
|
| 133 |
)
|