AIRider commited on
Commit
506884e
ยท
verified ยท
1 Parent(s): 06c8a5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -20
app.py CHANGED
@@ -78,24 +78,17 @@ def summarize_text(text):
78
  ๋Œ€๋ณธ:
79
  {text}
80
  """
81
- return call_api(prompt, max_tokens=8000, temperature=0.4, top_p=0.95)
82
 
83
- def display_content(title, script, summary):
84
  return f"""
85
- <div style="display: flex; flex-direction: column; gap: 20px;">
86
- <div style="flex: 1;">
87
- <h2 style='font-size:24px;'>{title}</h2>
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
- <h2 style='font-size:24px;'>{title}</h2>
93
- <details>
94
- <summary><h3>์›๋ฌธ ์Šคํฌ๋ฆฝํŠธ (ํด๋ฆญํ•˜์—ฌ ํŽผ์น˜๊ธฐ)</h3></summary>
95
- <div style="white-space: pre-wrap; background-color: #e0e0e0; padding: 15px; border-radius: 5px;">{script}</div>
96
- </details>
97
- </div>
98
- </div>
99
  """
100
 
101
  def analyze(url, cache):
@@ -108,15 +101,19 @@ def analyze(url, cache):
108
  title, script = get_youtube_script(url)
109
  cache = {"url": url, "title": title, "script": script}
110
 
 
 
 
 
 
111
  summary = summarize_text(script)
112
- content_html = display_content(title, script, summary)
113
-
114
- logging.info("๋ถ„์„ ์™„๋ฃŒ")
115
- return content_html, cache
116
  except Exception as e:
117
  error_msg = f"์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
118
  logging.exception(error_msg)
119
- return error_msg, cache
120
 
121
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค
122
  with gr.Blocks() as demo:
 
78
  ๋Œ€๋ณธ:
79
  {text}
80
  """
81
+ return call_api(prompt, max_tokens=2000, temperature=0.3, top_p=0.9)
82
 
83
+ def create_collapsible_section(section_title, video_title, content):
84
  return f"""
85
+ <details>
86
+ <summary style="cursor: pointer; font-weight: bold;">{section_title}</summary>
87
+ <div style="margin-top: 10px;">
88
+ <h3 style="font-size: 18px; margin-bottom: 10px;">{video_title}</h3>
89
+ <div style="white-space: pre-wrap; background-color: #f0f0f0; padding: 15px; border-radius: 5px;">{content}</div>
90
  </div>
91
+ </details>
 
 
 
 
 
 
 
92
  """
93
 
94
  def analyze(url, cache):
 
101
  title, script = get_youtube_script(url)
102
  cache = {"url": url, "title": title, "script": script}
103
 
104
+ # ์›๋ฌธ ์Šคํฌ๋ฆฝํŠธ ์„น์…˜ ์ƒ์„ฑ
105
+ script_section = create_collapsible_section("์›๋ฌธ ์Šคํฌ๋ฆฝํŠธ", title, script)
106
+ yield script_section, cache
107
+
108
+ # ์š”์•ฝ ์ƒ์„ฑ ๋ฐ ์„น์…˜ ์ƒ์„ฑ
109
  summary = summarize_text(script)
110
+ summary_section = create_collapsible_section("์š”์•ฝ", title, summary)
111
+ yield script_section + summary_section, cache
112
+
 
113
  except Exception as e:
114
  error_msg = f"์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
115
  logging.exception(error_msg)
116
+ yield error_msg, cache
117
 
118
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค
119
  with gr.Blocks() as demo: