openfree commited on
Commit
1be852d
Β·
verified Β·
1 Parent(s): 1186178

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -9
app.py CHANGED
@@ -3,6 +3,9 @@ import os
3
  os.environ["TORCH_DYNAMO_DISABLE"] = "1"
4
 
5
  import torch
 
 
 
6
  import torch._dynamo
7
  import gradio as gr
8
  import spaces
@@ -28,14 +31,20 @@ import pytesseract
28
  from pdf2image import convert_from_path
29
 
30
  # -------------------- μΆ”κ°€: PDF to Markdown λ³€ν™˜ κ΄€λ ¨ import --------------------
31
- import re
32
- import requests
33
- from bs4 import BeautifulSoup
34
- import urllib.request
35
- import ocrmypdf
36
- import pytz
37
- import urllib.parse
38
- from pypdf import PdfReader
 
 
 
 
 
 
39
  # ---------------------------------------------------------------------------
40
 
41
  # --------------------
@@ -721,7 +730,10 @@ def stream_chat(
721
  clear_cuda_memory()
722
 
723
  except Exception as e:
724
- error_message = f"였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}"
 
 
 
725
  print(f"Stream chat 였λ₯˜: {error_message}")
726
  clear_cuda_memory()
727
  yield "", history + [[message, error_message]]
 
3
  os.environ["TORCH_DYNAMO_DISABLE"] = "1"
4
 
5
  import torch
6
+ # μ„±λŠ₯ μ΅œμ ν™”λ₯Ό μœ„ν•œ μ„€μ • (TensorFloat32 μ—°μ‚° ν™œμ„±ν™”)
7
+ torch.set_float32_matmul_precision('high')
8
+
9
  import torch._dynamo
10
  import gradio as gr
11
  import spaces
 
31
  from pdf2image import convert_from_path
32
 
33
  # -------------------- μΆ”κ°€: PDF to Markdown λ³€ν™˜ κ΄€λ ¨ import --------------------
34
+ try:
35
+ import re
36
+ import requests
37
+ from bs4 import BeautifulSoup
38
+ import urllib.request
39
+ import ocrmypdf
40
+ import pytz
41
+ import urllib.parse
42
+ from pypdf import PdfReader
43
+ except ModuleNotFoundError as e:
44
+ raise ModuleNotFoundError(
45
+ "ν•„μˆ˜ λͺ¨λ“ˆμ΄ λˆ„λ½λ˜μ—ˆμŠ΅λ‹ˆλ‹€. 'beautifulsoup4' νŒ¨ν‚€μ§€λ₯Ό μ„€μΉ˜ν•΄μ£Όμ„Έμš”.\n"
46
+ "예: pip install beautifulsoup4"
47
+ )
48
  # ---------------------------------------------------------------------------
49
 
50
  # --------------------
 
730
  clear_cuda_memory()
731
 
732
  except Exception as e:
733
+ # μ˜ˆμ™Έ λ°œμƒ μ‹œ μ˜ˆμ™Έμ˜ 전체 정보λ₯Ό 좜λ ₯ν•˜μ—¬ 디버깅에 도움이 λ˜λ„λ‘ 함
734
+ import traceback
735
+ error_details = traceback.format_exc()
736
+ error_message = f"였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}\n{error_details}"
737
  print(f"Stream chat 였λ₯˜: {error_message}")
738
  clear_cuda_memory()
739
  yield "", history + [[message, error_message]]