mroccuper commited on
Commit
bbfb2ba
·
verified ·
1 Parent(s): 6dceb0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -24,9 +24,7 @@ Output structure:
24
  2. Post body: 2–4 paragraphs, casual tone, share what worked/didn’t, and end with a relatable or curious question.
25
 
26
  CONTENT TO CONVERT:
27
- """
28
- {content}
29
- """
30
  """
31
 
32
  # Function to handle generation
@@ -34,8 +32,10 @@ def generate_post(file, platform, styles, emotions):
34
  if not file:
35
  return "Please upload a file."
36
 
 
37
  raw_html = file.read().decode("utf-8")
38
  plain_text = html2text.html2text(raw_html)
 
39
  prompt = build_prompt(plain_text, platform, styles, emotions)
40
  response = model.generate_content(prompt)
41
  return response.text
@@ -47,10 +47,18 @@ with gr.Blocks(title="Reddit/Quora Post Generator") as demo:
47
  with gr.Row():
48
  file_input = gr.File(label="Upload HTML file", file_types=[".html"])
49
  platform = gr.Dropdown(["Reddit", "Quora"], label="Select Platform", value="Reddit")
50
-
51
  with gr.Row():
52
- styles = gr.CheckboxGroup(["Humanized", "Friendly", "Personal/Storytelling"], label="Writing Style", value=["Humanized"])
53
- emotions = gr.CheckboxGroup(["Curious", "Enthusiastic", "Skeptical", "Inspiring"], label="Emotional Tone", value=["Curious"])
 
 
 
 
 
 
 
 
54
 
55
  generate_btn = gr.Button("Generate Post")
56
  output = gr.Textbox(label="Generated Post", lines=15)
 
24
  2. Post body: 2–4 paragraphs, casual tone, share what worked/didn’t, and end with a relatable or curious question.
25
 
26
  CONTENT TO CONVERT:
27
+ \"\"\"{content}\"\"\"
 
 
28
  """
29
 
30
  # Function to handle generation
 
32
  if not file:
33
  return "Please upload a file."
34
 
35
+ # Read and convert HTML file
36
  raw_html = file.read().decode("utf-8")
37
  plain_text = html2text.html2text(raw_html)
38
+
39
  prompt = build_prompt(plain_text, platform, styles, emotions)
40
  response = model.generate_content(prompt)
41
  return response.text
 
47
  with gr.Row():
48
  file_input = gr.File(label="Upload HTML file", file_types=[".html"])
49
  platform = gr.Dropdown(["Reddit", "Quora"], label="Select Platform", value="Reddit")
50
+
51
  with gr.Row():
52
+ styles = gr.CheckboxGroup(
53
+ ["Humanized", "Friendly", "Personal/Storytelling"],
54
+ label="Writing Style",
55
+ value=["Humanized"]
56
+ )
57
+ emotions = gr.CheckboxGroup(
58
+ ["Curious", "Enthusiastic", "Skeptical", "Inspiring"],
59
+ label="Emotional Tone",
60
+ value=["Curious"]
61
+ )
62
 
63
  generate_btn = gr.Button("Generate Post")
64
  output = gr.Textbox(label="Generated Post", lines=15)