abrah926 commited on
Commit
29d1f72
Β·
verified Β·
1 Parent(s): a124d51

using data.dir for datasets

Browse files
Files changed (1) hide show
  1. app.py +25 -7
app.py CHANGED
@@ -5,6 +5,7 @@ import faiss
5
  import numpy as np
6
  import os
7
  import time
 
8
 
9
  # βœ… Ensure FAISS is installed
10
  os.system("pip install faiss-cpu")
@@ -12,15 +13,32 @@ os.system("pip install faiss-cpu")
12
  def log(message):
13
  print(f"βœ… {message}")
14
 
15
- # βœ… Load the datasets
16
- log("πŸ“₯ Loading datasets...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  datasets = {
18
- "sales": load_dataset("goendalf666/sales-conversations", trust_remote_code=True),
19
- "blended": load_dataset("blended_skill_talk", trust_remote_code=True),
20
- "dialog": load_dataset("daily_dialog", trust_remote_code=True),
21
- "multiwoz": load_dataset("multi_woz_v22", trust_remote_code=True),
22
  }
23
- log("βœ… Datasets loaded.")
 
 
24
 
25
  # βœ… Step 1: Run Embedding Script (Import and Run)
26
  log("πŸš€ Running embeddings script...")
 
5
  import numpy as np
6
  import os
7
  import time
8
+ import json
9
 
10
  # βœ… Ensure FAISS is installed
11
  os.system("pip install faiss-cpu")
 
13
  def log(message):
14
  print(f"βœ… {message}")
15
 
16
+
17
+ DATA_DIR = "data"
18
+
19
+ def load_local_dataset(dataset_name):
20
+ """Load a dataset from a JSON file."""
21
+ file_path = os.path.join(DATA_DIR, f"{dataset_name}.json")
22
+
23
+ if os.path.exists(file_path):
24
+ with open(file_path, "r") as f:
25
+ data = json.load(f)
26
+ print(f"βœ… Loaded {dataset_name} from {file_path}")
27
+ return data
28
+ else:
29
+ print(f"❌ ERROR: {dataset_name} file not found!")
30
+ return None
31
+
32
+ # βœ… Load all datasets from local storage
33
  datasets = {
34
+ "sales": load_local_dataset("sales"),
35
+ "blended": load_local_dataset("blended"),
36
+ "dialog": load_local_dataset("dialog"),
37
+ "multiwoz": load_local_dataset("multiwoz"),
38
  }
39
+
40
+ print("βœ… Datasets loaded from local storage!")
41
+
42
 
43
  # βœ… Step 1: Run Embedding Script (Import and Run)
44
  log("πŸš€ Running embeddings script...")