mroccuper commited on
Commit
fe92e03
Β·
verified Β·
1 Parent(s): 97250c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -31
app.py CHANGED
@@ -58,24 +58,16 @@ User may provide raw facts, a bio, a business update, or a rough news draft.
58
  - Return a fully structured PR article with HTML formatting.
59
  - At the END of the article, include a separate section with SEO metadata formatted as an HTML list:
60
  <h3>SEO Metadata</h3>
61
- <ul>
62
- <p><strong>βœ… Meta Title:</strong> [Your suggested title here]</p>
63
- <p><strong>βœ… Meta Description:</strong> [Your suggested description here]</p>
64
- <p><strong>βœ… Target Keyword:</strong> [Your suggested keyword here]</p>
65
- </ul>
66
  - Do NOT wrap the output in ```html or ``` markdown blocks.
67
 
68
- ✨ ADVANCED FEATURES TO ENHANCE CREDIBILITY AND USABILITY:
69
- - Auto-detect primary keyword if not provided
70
- - Insert Schema.org metadata snippets for Articles
71
- - Add Google News compatibility tags if requested
72
- - Offer multiple headline variants (A/B test style)
73
- - Calibrate tone on a slider: "Journalistic" to "Brand Voice"
74
- - Export HTML, PDF, or plain text
75
- - One-click publish to Notion or Ghost CMS
76
-
77
  Please transform the following content into a professional PR-style article:
78
  """
 
79
  def clean_html_output(self, text):
80
  """Remove markdown code blocks and clean HTML output"""
81
  # Remove markdown code blocks (```html, ```HTML, ```, etc.)
@@ -194,16 +186,13 @@ Please transform the following content into a professional PR-style article:
194
 
195
  return "\n".join(suggestions)
196
 
197
- def generate_article(self, api_key, content, max_length=4000):
198
  """Generate PR-style article using Gemini API"""
199
  if not api_key.strip():
200
  return "❌ Error: Please enter your Gemini API key", "", None
201
 
202
  if not content.strip():
203
  return "❌ Error: Please enter content to transform", "", None
204
-
205
- if len(content) > max_length:
206
- return f"❌ Error: Content exceeds {max_length} characters limit", "", None
207
 
208
  model, error = self.setup_gemini(api_key)
209
  if error:
@@ -298,15 +287,6 @@ def create_interface():
298
  max_lines=20
299
  )
300
 
301
- with gr.Row():
302
- max_length_slider = gr.Slider(
303
- minimum=1000,
304
- maximum=7000,
305
- value=4000,
306
- step=500,
307
- label="πŸ“ Max Input Length (characters)"
308
- )
309
-
310
  generate_btn = gr.Button(
311
  "πŸš€ Generate PR Article",
312
  variant="primary",
@@ -324,7 +304,7 @@ def create_interface():
324
 
325
  download_file = gr.File(
326
  label="πŸ“₯ Download HTML Article",
327
- interactive=True
328
  )
329
 
330
  with gr.Row():
@@ -332,19 +312,19 @@ def create_interface():
332
  gr.HTML("<h3>🎨 Generated Article Preview</h3>")
333
  article_output = gr.HTML(
334
  label="Generated PR Article",
335
- show_label=True
336
  )
337
 
338
  # Event handlers
339
  generate_btn.click(
340
  fn=generator.generate_article,
341
- inputs=[api_key_input, content_input, max_length_slider],
342
  outputs=[status_output, article_output, download_file]
343
  )
344
 
345
  # Add examples
346
  gr.HTML("""
347
- <div style="margin-top: 30px; padding: 20px; border-radius: 10px;">
348
  <h3>πŸ’‘ Example Input Content:</h3>
349
  <p><strong>Business Acquisition:</strong> "Tech entrepreneur John Smith announced the acquisition of downtown office building for $15M. Smith, who previously founded two successful startups, plans to convert the space into a modern co-working hub."</p>
350
  <p><strong>Product Launch:</strong> "AI company releases new software that reduces processing time by 60%. The tool has been tested by 500+ businesses with positive results."</p>
@@ -365,4 +345,5 @@ if __name__ == "__main__":
365
 
366
  app = create_interface()
367
  app.launch(
 
368
  )
 
58
  - Return a fully structured PR article with HTML formatting.
59
  - At the END of the article, include a separate section with SEO metadata formatted as an HTML list:
60
  <h3>SEO Metadata</h3>
61
+ <ul>
62
+ <li><strong>Meta Title:</strong> [Your suggested title here]</li>
63
+ <li><strong>Meta Description:</strong> [Your suggested description here]</li>
64
+ <li><strong>Target Keyword:</strong> [Your suggested keyword here]</li>
65
+ </ul>
66
  - Do NOT wrap the output in ```html or ``` markdown blocks.
67
 
 
 
 
 
 
 
 
 
 
68
  Please transform the following content into a professional PR-style article:
69
  """
70
+
71
  def clean_html_output(self, text):
72
  """Remove markdown code blocks and clean HTML output"""
73
  # Remove markdown code blocks (```html, ```HTML, ```, etc.)
 
186
 
187
  return "\n".join(suggestions)
188
 
189
+ def generate_article(self, api_key, content, max_length=None):
190
  """Generate PR-style article using Gemini API"""
191
  if not api_key.strip():
192
  return "❌ Error: Please enter your Gemini API key", "", None
193
 
194
  if not content.strip():
195
  return "❌ Error: Please enter content to transform", "", None
 
 
 
196
 
197
  model, error = self.setup_gemini(api_key)
198
  if error:
 
287
  max_lines=20
288
  )
289
 
 
 
 
 
 
 
 
 
 
290
  generate_btn = gr.Button(
291
  "πŸš€ Generate PR Article",
292
  variant="primary",
 
304
 
305
  download_file = gr.File(
306
  label="πŸ“₯ Download HTML Article",
307
+ interactive=False
308
  )
309
 
310
  with gr.Row():
 
312
  gr.HTML("<h3>🎨 Generated Article Preview</h3>")
313
  article_output = gr.HTML(
314
  label="Generated PR Article",
315
+ show_label=False
316
  )
317
 
318
  # Event handlers
319
  generate_btn.click(
320
  fn=generator.generate_article,
321
+ inputs=[api_key_input, content_input],
322
  outputs=[status_output, article_output, download_file]
323
  )
324
 
325
  # Add examples
326
  gr.HTML("""
327
+ <div style="margin-top: 30px; padding: 20px;border-radius: 10px;">
328
  <h3>πŸ’‘ Example Input Content:</h3>
329
  <p><strong>Business Acquisition:</strong> "Tech entrepreneur John Smith announced the acquisition of downtown office building for $15M. Smith, who previously founded two successful startups, plans to convert the space into a modern co-working hub."</p>
330
  <p><strong>Product Launch:</strong> "AI company releases new software that reduces processing time by 60%. The tool has been tested by 500+ businesses with positive results."</p>
 
345
 
346
  app = create_interface()
347
  app.launch(
348
+
349
  )