fantaxy commited on
Commit
89931e7
ยท
verified ยท
1 Parent(s): 0e2de0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gradio as gr
2
  import requests
3
  from bs4 import BeautifulSoup
@@ -20,7 +21,6 @@ from urllib.parse import urljoin
20
  import requests
21
  from pexels_api import API
22
  import logging
23
- import random
24
 
25
  # ๋กœ๊น… ์„ค์ •
26
  logging.basicConfig(level=logging.INFO)
@@ -620,13 +620,18 @@ def convert_markdown_images(content):
620
 
621
  return content
622
 
 
623
  def process_all_titles(category, style, topic, num_titles):
624
  title_suggestions, _ = suggest_title(category, style, topic, "", "", "")
625
  titles = title_suggestions.split('\n')
 
 
 
626
 
627
  results = []
628
  for title in titles[:num_titles]:
629
  try:
 
630
  # ์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€ URL ๊ฐ€์ ธ์˜ค๊ธฐ
631
  image_url_1 = get_image_url(topic)
632
 
@@ -706,7 +711,7 @@ with gr.Blocks() as demo:
706
  gr.Markdown("### 3๋‹จ๊ณ„ : ๋ธ”๋กœ๊ทธ ์ฃผ์ œ, ๋˜๋Š” ํ‚ค์›Œ๋“œ๋ฅผ ์ƒ์„ธํžˆ ์ž…๋ ฅํ•˜์„ธ์š”")
707
  topic = gr.Textbox(label="๋ธ”๋กœ๊ทธ ์ฃผ์ œ", placeholder="์˜ˆ์‹œ: 8์›” ๊ตญ๋‚ด ์—ฌํ–‰์ง€ ์ถ”์ฒœ")
708
 
709
- gr.Markdown("### 4๋‹จ๊ณ„ : ์ž๋™ ์ƒ์„ฑ ๋ฐ ์ „์†กํ•  ๋ธ”๋กœ๊ทธ ์ˆ˜(๊ณ„์ •๋‹น ์ผ์ผ ํฌ์ŠคํŒ… ์—…๋กœ๋“œ ์ œํ•œ 60๊ฑด๊นŒ)")
710
  num_titles = gr.Slider(minimum=1, maximum=60, value=2, step=1, label="ํฌ์ŠคํŒ… ๊ฑด")
711
 
712
  start_btn = gr.Button("์‹œ์ž‘")
 
1
+ import html
2
  import gradio as gr
3
  import requests
4
  from bs4 import BeautifulSoup
 
21
  import requests
22
  from pexels_api import API
23
  import logging
 
24
 
25
  # ๋กœ๊น… ์„ค์ •
26
  logging.basicConfig(level=logging.INFO)
 
620
 
621
  return content
622
 
623
+
624
  def process_all_titles(category, style, topic, num_titles):
625
  title_suggestions, _ = suggest_title(category, style, topic, "", "", "")
626
  titles = title_suggestions.split('\n')
627
+
628
+ # ๋นˆ ๋ฌธ์ž์—ด์ด๋‚˜ '###' ๋“ฑ์˜ ๋ถˆํ•„์š”ํ•œ ๋ฌธ์ž์—ด ์ œ๊ฑฐ
629
+ titles = [title.strip() for title in titles if title.strip() and not title.strip().startswith('###')]
630
 
631
  results = []
632
  for title in titles[:num_titles]:
633
  try:
634
+
635
  # ์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€ URL ๊ฐ€์ ธ์˜ค๊ธฐ
636
  image_url_1 = get_image_url(topic)
637
 
 
711
  gr.Markdown("### 3๋‹จ๊ณ„ : ๋ธ”๋กœ๊ทธ ์ฃผ์ œ, ๋˜๋Š” ํ‚ค์›Œ๋“œ๋ฅผ ์ƒ์„ธํžˆ ์ž…๋ ฅํ•˜์„ธ์š”")
712
  topic = gr.Textbox(label="๋ธ”๋กœ๊ทธ ์ฃผ์ œ", placeholder="์˜ˆ์‹œ: 8์›” ๊ตญ๋‚ด ์—ฌํ–‰์ง€ ์ถ”์ฒœ")
713
 
714
+ gr.Markdown("### 4๋‹จ๊ณ„ : ์ž๋™ ์ƒ์„ฑ ๋ฐ ์ „์†กํ•  ๋ธ”๋กœ๊ทธ ์ˆ˜(๊ณ„์ •๋‹น ์ผ์ผ ํฌ์ŠคํŒ… ์—…๋กœ๋“œ ์ œํ•œ 60๊ฑด๊นŒ์ง€ )")
715
  num_titles = gr.Slider(minimum=1, maximum=60, value=2, step=1, label="ํฌ์ŠคํŒ… ๊ฑด")
716
 
717
  start_btn = gr.Button("์‹œ์ž‘")