Ali2206 commited on
Commit
d7cd741
·
verified ·
1 Parent(s): caad2f2

Update ui/ui_core.py

Browse files
Files changed (1) hide show
  1. ui/ui_core.py +7 -0
ui/ui_core.py CHANGED
@@ -7,10 +7,17 @@ import gradio as gr
7
  from typing import List
8
  from concurrent.futures import ThreadPoolExecutor, as_completed
9
  import hashlib
 
10
 
11
  # ✅ Fix: Add src to Python path
12
  sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src")))
13
 
 
 
 
 
 
 
14
  from txagent.txagent import TxAgent
15
 
16
  def sanitize_utf8(text: str) -> str:
 
7
  from typing import List
8
  from concurrent.futures import ThreadPoolExecutor, as_completed
9
  import hashlib
10
+ import shutil
11
 
12
  # ✅ Fix: Add src to Python path
13
  sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src")))
14
 
15
+ # ✅ Persist model cache to Hugging Face Space's /data directory
16
+ model_cache_dir = "/data/txagent_models"
17
+ os.makedirs(model_cache_dir, exist_ok=True)
18
+ os.environ["TRANSFORMERS_CACHE"] = model_cache_dir
19
+ os.environ["HF_HOME"] = model_cache_dir
20
+
21
  from txagent.txagent import TxAgent
22
 
23
  def sanitize_utf8(text: str) -> str: