Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,18 +73,29 @@ def summarize_text(text):
|
|
| 73 |
8. ๋๋ณธ์์ ์ ๋ฌํ๋ ๊ฐ์ ์ด๋ ๋ถ์๊ธฐ๋ ํฌํจ
|
| 74 |
9. ๋ฐ๋์ ๊ธฐ์ ์ ์ฉ์ด๋ ์ ๋ฌธ ์ฉ์ด๊ฐ ์์ ๊ฒฝ์ฐ, ์ด๋ฅผ ์ ํํ๊ฒ ์ฌ์ฉ
|
| 75 |
10. ๋๋ณธ์ ๋ชฉ์ ์ด๋ ์๋๋ฅผ ํ์
ํ๊ณ , ์ด๋ฅผ ์์ฝ์ ๋ฐ๋์ ๋ฐ์
|
|
|
|
| 76 |
|
| 77 |
๋๋ณธ:
|
| 78 |
{text}
|
| 79 |
"""
|
| 80 |
return call_api(prompt, max_tokens=2000, temperature=0.3, top_p=0.9)
|
| 81 |
|
| 82 |
-
def
|
| 83 |
-
return f"""
|
| 84 |
-
<
|
| 85 |
-
|
| 86 |
-
<div style="
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
def analyze(url, cache):
|
| 90 |
try:
|
|
@@ -96,29 +107,28 @@ def analyze(url, cache):
|
|
| 96 |
title, script = get_youtube_script(url)
|
| 97 |
cache = {"url": url, "title": title, "script": script}
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
|
| 102 |
logging.info("๋ถ์ ์๋ฃ")
|
| 103 |
-
return
|
| 104 |
except Exception as e:
|
| 105 |
error_msg = f"์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
| 106 |
logging.exception(error_msg)
|
| 107 |
-
return error_msg,
|
| 108 |
|
| 109 |
# Gradio ์ธํฐํ์ด์ค
|
| 110 |
with gr.Blocks() as demo:
|
| 111 |
gr.Markdown("## YouTube ์คํฌ๋ฆฝํธ ์ถ์ถ ๋ฐ ์์ฝ ๋๊ตฌ")
|
| 112 |
youtube_url_input = gr.Textbox(label="YouTube URL ์
๋ ฅ")
|
| 113 |
analyze_button = gr.Button("๋ถ์ํ๊ธฐ")
|
| 114 |
-
|
| 115 |
-
summary_output = gr.HTML(label="์ ์ฒด ์์ฝ")
|
| 116 |
cached_data = gr.State({"url": "", "title": "", "script": ""})
|
| 117 |
|
| 118 |
analyze_button.click(
|
| 119 |
analyze,
|
| 120 |
inputs=[youtube_url_input, cached_data],
|
| 121 |
-
outputs=[
|
| 122 |
)
|
| 123 |
|
| 124 |
if __name__ == "__main__":
|
|
|
|
| 73 |
8. ๋๋ณธ์์ ์ ๋ฌํ๋ ๊ฐ์ ์ด๋ ๋ถ์๊ธฐ๋ ํฌํจ
|
| 74 |
9. ๋ฐ๋์ ๊ธฐ์ ์ ์ฉ์ด๋ ์ ๋ฌธ ์ฉ์ด๊ฐ ์์ ๊ฒฝ์ฐ, ์ด๋ฅผ ์ ํํ๊ฒ ์ฌ์ฉ
|
| 75 |
10. ๋๋ณธ์ ๋ชฉ์ ์ด๋ ์๋๋ฅผ ํ์
ํ๊ณ , ์ด๋ฅผ ์์ฝ์ ๋ฐ๋์ ๋ฐ์
|
| 76 |
+
11. ๊ฐ ๋ฌธ์ฅ์ ๋ช
ํํ๊ฒ ๊ตฌ๋ถํ๊ณ , ์ ์ ํ ๋จ๋ฝ ๊ตฌ๋ถ์ ์ฌ์ฉํ์ฌ ๊ฐ๋
์ฑ์ ๋์ด์์ค
|
| 77 |
|
| 78 |
๋๋ณธ:
|
| 79 |
{text}
|
| 80 |
"""
|
| 81 |
return call_api(prompt, max_tokens=2000, temperature=0.3, top_p=0.9)
|
| 82 |
|
| 83 |
+
def display_content(title, script, summary):
|
| 84 |
+
return f"""
|
| 85 |
+
<h2 style='font-size:24px;'>{title}</h2>
|
| 86 |
+
<div style="display: flex; flex-direction: column; gap: 20px;">
|
| 87 |
+
<div style="flex: 1;">
|
| 88 |
+
<h3>์์ฝ</h3>
|
| 89 |
+
<div style="white-space: pre-wrap; background-color: #f0f0f0; padding: 15px; border-radius: 5px;">{summary}</div>
|
| 90 |
+
</div>
|
| 91 |
+
<div style="flex: 1;">
|
| 92 |
+
<details>
|
| 93 |
+
<summary><h3>์๋ฌธ ์คํฌ๋ฆฝํธ (ํด๋ฆญํ์ฌ ํผ์น๊ธฐ)</h3></summary>
|
| 94 |
+
<div style="white-space: pre-wrap; background-color: #e0e0e0; padding: 15px; border-radius: 5px;">{script}</div>
|
| 95 |
+
</details>
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
"""
|
| 99 |
|
| 100 |
def analyze(url, cache):
|
| 101 |
try:
|
|
|
|
| 107 |
title, script = get_youtube_script(url)
|
| 108 |
cache = {"url": url, "title": title, "script": script}
|
| 109 |
|
| 110 |
+
summary = summarize_text(script)
|
| 111 |
+
content_html = display_content(title, script, summary)
|
| 112 |
|
| 113 |
logging.info("๋ถ์ ์๋ฃ")
|
| 114 |
+
return content_html, cache
|
| 115 |
except Exception as e:
|
| 116 |
error_msg = f"์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
| 117 |
logging.exception(error_msg)
|
| 118 |
+
return error_msg, cache
|
| 119 |
|
| 120 |
# Gradio ์ธํฐํ์ด์ค
|
| 121 |
with gr.Blocks() as demo:
|
| 122 |
gr.Markdown("## YouTube ์คํฌ๋ฆฝํธ ์ถ์ถ ๋ฐ ์์ฝ ๋๊ตฌ")
|
| 123 |
youtube_url_input = gr.Textbox(label="YouTube URL ์
๋ ฅ")
|
| 124 |
analyze_button = gr.Button("๋ถ์ํ๊ธฐ")
|
| 125 |
+
content_output = gr.HTML(label="๋ด์ฉ")
|
|
|
|
| 126 |
cached_data = gr.State({"url": "", "title": "", "script": ""})
|
| 127 |
|
| 128 |
analyze_button.click(
|
| 129 |
analyze,
|
| 130 |
inputs=[youtube_url_input, cached_data],
|
| 131 |
+
outputs=[content_output, cached_data]
|
| 132 |
)
|
| 133 |
|
| 134 |
if __name__ == "__main__":
|