Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,11 @@ from sentence_transformers import SentenceTransformer
|
|
7 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
8 |
from preprocess import preprocess
|
9 |
|
|
|
|
|
|
|
10 |
|
|
|
11 |
# Check if precomputed files exist and run preprocessing if needed
|
12 |
if not (os.path.exists("chunks.pkl") and os.path.exists("index.faiss")):
|
13 |
print("Precomputed files missing. Running preprocess.py...")
|
@@ -26,10 +30,8 @@ embedding_model = SentenceTransformer("sentence-transformers/paraphrase-multilin
|
|
26 |
|
27 |
# Load Jais model and tokenizer
|
28 |
model_name = "inceptionai/jais-13b"
|
29 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
30 |
-
model = AutoModelForCausalLM.from_pretrained(model_name
|
31 |
-
|
32 |
-
|
33 |
|
34 |
# RAG function
|
35 |
def get_response(query, k=3):
|
|
|
7 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
8 |
from preprocess import preprocess
|
9 |
|
10 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
11 |
+
if not HF_TOKEN:
|
12 |
+
raise ValueError("HF_TOKEN environment variable not set. Please configure it in Space settings.")
|
13 |
|
14 |
+
|
15 |
# Check if precomputed files exist and run preprocessing if needed
|
16 |
if not (os.path.exists("chunks.pkl") and os.path.exists("index.faiss")):
|
17 |
print("Precomputed files missing. Running preprocess.py...")
|
|
|
30 |
|
31 |
# Load Jais model and tokenizer
|
32 |
model_name = "inceptionai/jais-13b"
|
33 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, token=HF_TOKEN)
|
34 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, token=HF_TOKEN
|
|
|
|
|
35 |
|
36 |
# RAG function
|
37 |
def get_response(query, k=3):
|