InnovisionLLC commited on
Commit
5015f69
·
1 Parent(s): 23efb83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -29,23 +29,37 @@ large_text_theme = Base(
29
 
30
 
31
  CONFIG_PATH = "config.json"
 
 
 
32
 
33
  DEFAULT_LLM = "Jatin19K/unsloth-q5_k_m-mistral-nemo-instruct-2407"
34
  DEFAULT_VECTOR_STORE = "CFIR"
35
 
 
 
 
 
 
36
  token = os.getenv("HF_TOKEN")
37
  dataset_id = os.getenv("DATASET_ID")
38
 
 
 
 
39
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- local_dir = snapshot_download(
42
- repo_id=dataset_id,
43
- repo_type="dataset",
44
- token=token
45
- )
46
-
47
- EMBED_MODEL_PATH = os.path.join(local_dir, "bge_onnx")
48
- VECTOR_STORE_DIR = os.path.join(local_dir, "vector_stores")
49
 
50
  class ModelManager:
51
  def __init__(self):
 
29
 
30
 
31
  CONFIG_PATH = "config.json"
32
+ PERSISTENT_DIR = "/data"
33
+
34
+ FORCE_UPDATE_FLAG = False
35
 
36
  DEFAULT_LLM = "Jatin19K/unsloth-q5_k_m-mistral-nemo-instruct-2407"
37
  DEFAULT_VECTOR_STORE = "CFIR"
38
 
39
+
40
+ EMBED_MODEL_PATH = os.path.join(PERSISTENT_DIR, "bge_onnx")
41
+ VECTOR_STORE_DIR = os.path.join(PERSISTENT_DIR, "vector_stores")
42
+
43
+
44
  token = os.getenv("HF_TOKEN")
45
  dataset_id = os.getenv("DATASET_ID")
46
 
47
+ def download_data_if_needed():
48
+ if not os.path.exists(EMBED_MODEL_PATH) or not os.path.exists(VECTOR_STORE_DIR):
49
+ FORCE_UPDATE_FLAG = True
50
 
51
+ if FORCE_UPDATE_FLAG:
52
+ snapshot_download(
53
+ repo_id=dataset_id,
54
+ repo_type="dataset",
55
+ token=token,
56
+ local_dir=PERSISTENT_DIR
57
+ )
58
+ print("Data downloaded successfully.")
59
+ else:
60
+ print("Data exists.")
61
 
62
+ download_data_if_needed()
 
 
 
 
 
 
 
63
 
64
  class ModelManager:
65
  def __init__(self):