SNA-AI commited on
Commit
5534c0f
Β·
verified Β·
1 Parent(s): 3bb2daa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -23
app.py CHANGED
@@ -2,14 +2,14 @@ import gradio as gr
2
  import requests
3
  import os
4
 
5
- API_KEY = os.getenv("groc_api_key")
6
  API_URL = "https://api.groq.com/openai/v1/chat/completions"
7
 
8
 
9
- def generate_linkedin_post(topic, tone, audience, length):
10
 
11
  prompt = f"""
12
- Write a HIGHLY engaging LinkedIn post.
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
- - Start with a strong hook πŸ”₯
21
- - Add relevant emojis naturally πŸ˜„πŸš€πŸ’‘
22
- - Make it human, storytelling style
23
- - Keep it LinkedIn viral optimized
24
- - End with 5-8 hashtags
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 DESIGN
46
  css = """
47
  body {
48
- background: linear-gradient(135deg, #f5f7fb, #e8f0ff);
 
49
  }
50
 
 
51
  .gradio-container {
52
  max-width: 900px !important;
53
  margin: auto !important;
 
54
  }
55
 
56
- textarea {
57
- font-size: 16px !important;
 
 
 
 
 
 
 
 
 
58
  background: white !important;
59
- border-radius: 12px !important;
60
- border: 1px solid #dbeafe !important;
61
  }
62
 
 
63
  button {
64
- background: #2563eb !important;
65
  color: white !important;
66
- border-radius: 10px !important;
67
- font-weight: bold !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 + emojis + storytelling ✨
76
  """)
77
 
78
  with gr.Row():
79
- topic = gr.Textbox(label="πŸ’‘ Topic")
80
  tone = gr.Dropdown(
81
- ["Professional", "Motivational", "Casual", "Storytelling"],
82
  label="🎯 Tone"
83
  )
84
 
85
  with gr.Row():
86
- audience = gr.Textbox(label="πŸ‘₯ Target Audience")
87
  length = gr.Dropdown(["Short", "Medium", "Long"], label="πŸ“ Length")
88
 
89
- btn = gr.Button("✨ Generate Viral Post")
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
- generate_linkedin_post,
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
  )