Update app.py
Browse files
app.py
CHANGED
@@ -600,43 +600,37 @@ def generate_report(title, info, progress=gr.Progress()):
|
|
600 |
|
601 |
progress(0.5, desc="AI ๋ชจ๋ธ ์ฒ๋ฆฌ ์ค...")
|
602 |
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
return [
|
616 |
-
gr.update(value=formatted_response, visible=True),
|
617 |
-
gr.update(value="์ ๊ธฐ", visible=True)
|
618 |
-
]
|
619 |
-
else:
|
620 |
-
return [
|
621 |
-
gr.update(value="๋ฆฌํฌํ
์์ฑ์ ์คํจํ์ต๋๋ค.", visible=True),
|
622 |
-
gr.update(value="์ ๊ธฐ", visible=True)
|
623 |
-
]
|
624 |
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
631 |
|
632 |
except Exception as e:
|
633 |
-
print(f"
|
634 |
-
return [
|
635 |
-
gr.update(value="๋ฆฌํฌํ
์์ฑ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.", visible=True),
|
636 |
-
gr.update(value="์ ๊ธฐ", visible=True)
|
637 |
-
]
|
638 |
-
finally:
|
639 |
-
progress(1.0, desc="์๋ฃ!")
|
640 |
|
641 |
def toggle_report(report_content, show_report):
|
642 |
"""๋ฆฌํฌํธ ํ์/์จ๊น ํ ๊ธ"""
|
|
|
600 |
|
601 |
progress(0.5, desc="AI ๋ชจ๋ธ ์ฒ๋ฆฌ ์ค...")
|
602 |
|
603 |
+
# ์ต๋ 3๋ฒ ์ฌ์๋
|
604 |
+
max_retries = 3
|
605 |
+
for attempt in range(max_retries):
|
606 |
+
try:
|
607 |
+
response = hf_client.text_generation(
|
608 |
+
prompt,
|
609 |
+
max_new_tokens=2000, # ํ ํฐ ์ ์ค์
|
610 |
+
temperature=0.7,
|
611 |
+
repetition_penalty=1.2,
|
612 |
+
return_full_text=False,
|
613 |
+
max_time=180 # ํ์์์ 180์ด๋ก ์ฆ๊ฐ
|
614 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
615 |
|
616 |
+
if response:
|
617 |
+
progress(1.0, desc="์๋ฃ!")
|
618 |
+
formatted_response = f"### AI ๋ฆฌํฌํ
\n\n{response}"
|
619 |
+
return [formatted_response, gr.update(visible=True)]
|
620 |
+
|
621 |
+
except Exception as e:
|
622 |
+
if attempt < max_retries - 1:
|
623 |
+
print(f"Retry {attempt + 1}/{max_retries} after error: {str(e)}")
|
624 |
+
time.sleep(5) # 5์ด ๋๊ธฐ ํ ์ฌ์๋
|
625 |
+
continue
|
626 |
+
else:
|
627 |
+
raise e
|
628 |
+
|
629 |
+
return ["๋ฆฌํฌํ
์์ฑ์ ์คํจํ์ต๋๋ค. ๋ค์ ์๋ํด์ฃผ์ธ์.", gr.update(visible=True)]
|
630 |
|
631 |
except Exception as e:
|
632 |
+
print(f"Model error: {str(e)}")
|
633 |
+
return ["AI ๋ชจ๋ธ ์ฒ๋ฆฌ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. ์ ์ ํ ๋ค์ ์๋ํด์ฃผ์ธ์.", gr.update(visible=True)]
|
|
|
|
|
|
|
|
|
|
|
634 |
|
635 |
def toggle_report(report_content, show_report):
|
636 |
"""๋ฆฌํฌํธ ํ์/์จ๊น ํ ๊ธ"""
|