Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- rag_engine.py +10 -0
rag_engine.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
import time
|
| 2 |
import json
|
| 3 |
import re
|
|
@@ -14,6 +16,14 @@ from utils import normalize_arabic, detect_lang
|
|
| 14 |
|
| 15 |
class ENAEngine:
|
| 16 |
def __init__(self, groq_token=None):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
self.embeddings = HuggingFaceEmbeddings(
|
| 18 |
model_name=EMBED_MODEL,
|
| 19 |
model_kwargs={"device":"cpu"},
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import zipfile
|
| 3 |
import time
|
| 4 |
import json
|
| 5 |
import re
|
|
|
|
| 16 |
|
| 17 |
class ENAEngine:
|
| 18 |
def __init__(self, groq_token=None):
|
| 19 |
+
# Auto-extract DB if missing
|
| 20 |
+
if os.path.exists("chroma_ena_db.zip") and not os.path.exists(CHROMA_PATH):
|
| 21 |
+
try:
|
| 22 |
+
with zipfile.ZipFile("chroma_ena_db.zip", 'r') as zip_ref:
|
| 23 |
+
zip_ref.extractall(".")
|
| 24 |
+
except:
|
| 25 |
+
pass
|
| 26 |
+
|
| 27 |
self.embeddings = HuggingFaceEmbeddings(
|
| 28 |
model_name=EMBED_MODEL,
|
| 29 |
model_kwargs={"device":"cpu"},
|