Shubham170793 commited on
Commit
7c018b6
·
verified ·
1 Parent(s): 9b53064

Update src/qa.py

Browse files
Files changed (1) hide show
  1. src/qa.py +19 -0
src/qa.py CHANGED
@@ -22,6 +22,25 @@ from gen_ai_hub.proxy.langchain.openai import ChatOpenAI
22
 
23
  print("✅ qa.py (GPT-4o via Gen AI Hub + Bullet-Aware Retrieval + Cache) loaded from:", __file__)
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  # ==========================================================
26
  # 1️⃣ Hugging Face Cache Setup
27
  # ==========================================================
 
22
 
23
  print("✅ qa.py (GPT-4o via Gen AI Hub + Bullet-Aware Retrieval + Cache) loaded from:", __file__)
24
 
25
+ # ==========================================================
26
+ # 🧱 Permanent Embedding Cache Directory
27
+ # ==========================================================
28
+ CACHE_EMB_DIR = os.path.join(os.path.dirname(__file__), "embed_cache")
29
+ os.makedirs(CACHE_EMB_DIR, exist_ok=True)
30
+
31
+ # Verify write permission
32
+ try:
33
+ test_file = os.path.join(CACHE_EMB_DIR, "test_write.tmp")
34
+ with open(test_file, "w") as f:
35
+ f.write("ok")
36
+ os.remove(test_file)
37
+ print(f"✅ Cache directory ready and writable: {CACHE_EMB_DIR}")
38
+ except Exception as e:
39
+ print(f"⚠️ Cache directory not writable ({CACHE_EMB_DIR}): {e}")
40
+ CACHE_EMB_DIR = "/tmp/embed_cache"
41
+ os.makedirs(CACHE_EMB_DIR, exist_ok=True)
42
+ print(f"🔄 Fallback to temporary cache: {CACHE_EMB_DIR}")
43
+
44
  # ==========================================================
45
  # 1️⃣ Hugging Face Cache Setup
46
  # ==========================================================