Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -124,17 +124,32 @@ def generate_timeline_summary(sections):
|
|
| 124 |
{combined_sections}
|
| 125 |
"""
|
| 126 |
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
def summarize_text(text):
|
| 140 |
prompt = f"""
|
|
|
|
| 124 |
{combined_sections}
|
| 125 |
"""
|
| 126 |
|
| 127 |
+
try:
|
| 128 |
+
response = call_api(prompt, max_tokens=1000, temperature=0.3, top_p=0.9)
|
| 129 |
+
|
| 130 |
+
# μλ΅μ μ€ λ¨μλ‘ λΆλ¦¬νκ³ κ° μ€μ HTML νμμΌλ‘ λ³ν
|
| 131 |
+
timeline_items = response.strip().split('\n')
|
| 132 |
+
formatted_timeline = []
|
| 133 |
+
|
| 134 |
+
for item in timeline_items:
|
| 135 |
+
if ':' in item: # μκ° μ λ³΄κ° μλ νλͺ©λ§ μ²λ¦¬
|
| 136 |
+
time, summary = item.split(':', 1)
|
| 137 |
+
formatted_timeline.append(f"<p><strong>{time.strip()}</strong>:{summary.strip()}</p>")
|
| 138 |
+
|
| 139 |
+
timeline_html = "\n".join(formatted_timeline)
|
| 140 |
+
|
| 141 |
+
if not timeline_html:
|
| 142 |
+
raise ValueError("μ ν¨ν νμλΌμΈ μμ½μ μμ±νμ§ λͺ»νμ΅λλ€.")
|
| 143 |
+
|
| 144 |
+
return f"""
|
| 145 |
+
<h3>νμλΌμΈ μμ½:</h3>
|
| 146 |
+
<div style="white-space: pre-wrap; max-height: 400px; overflow-y: auto; border: 1px solid #ccc; padding: 10px;">
|
| 147 |
+
{timeline_html}
|
| 148 |
+
</div>
|
| 149 |
+
"""
|
| 150 |
+
except Exception as e:
|
| 151 |
+
logging.exception("νμλΌμΈ μμ½ μμ± μ€ μ€λ₯ λ°μ")
|
| 152 |
+
return "<p>νμλΌμΈ μμ½μ μμ±νλ μ€ μ€λ₯κ° λ°μνμ΅λλ€. λ€μ μλν΄ μ£ΌμΈμ.</p>"
|
| 153 |
|
| 154 |
def summarize_text(text):
|
| 155 |
prompt = f"""
|