Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,15 +8,15 @@ import os
|
|
8 |
# Percorsi per il primo file ZIP
|
9 |
zip_path_m = "faiss_manual_index.zip" # File ZIP per l'indice manuale
|
10 |
extraction_dir_m = "./extracted_models/faiss_manual_index" # Sottocartella per estrazione manuale
|
11 |
-
testm_dir =
|
12 |
|
13 |
# Percorsi per il secondo file ZIP
|
14 |
zip_path_p = "faiss_problems_index.zip" # File ZIP per l'indice problemi
|
15 |
extraction_dir_p = "./extracted_models/faiss_problems_index" # Sottocartella per estrazione problemi
|
16 |
-
testp_dir =
|
17 |
|
18 |
# Estrai il primo file ZIP se non esiste già
|
19 |
-
if not os.path.exists(testm_dir):
|
20 |
with zipfile.ZipFile(zip_path_m, 'r') as zip_ref:
|
21 |
zip_ref.extractall(extraction_dir_m)
|
22 |
print(f"Indice Manuale estratto correttamente nella cartella {extraction_dir_m}")
|
@@ -24,20 +24,17 @@ else:
|
|
24 |
print(f"Indice Manuale già presente in {testm_dir}")
|
25 |
|
26 |
# Estrai il secondo file ZIP se non esiste già
|
27 |
-
if not os.path.exists(testp_dir):
|
28 |
with zipfile.ZipFile(zip_path_p, 'r') as zip_ref:
|
29 |
zip_ref.extractall(extraction_dir_p)
|
30 |
print(f"Indice Problemi estratto correttamente nella cartella {extraction_dir_p}")
|
31 |
else:
|
32 |
print(f"Indice Problemi già presente in {testp_dir}")
|
33 |
|
34 |
-
|
35 |
-
|
36 |
# Carica il modello di embedding
|
37 |
embedding_model = HuggingFaceEmbeddings(model_name="sentence-transformers/LaBSE")
|
38 |
|
39 |
# Carica i vectorstore FAISS salvati
|
40 |
-
|
41 |
manual_vectorstore = FAISS.load_local(testm_dir, embedding_model, allow_dangerous_deserialization=True)
|
42 |
problems_vectorstore = FAISS.load_local(testp_dir, embedding_model, allow_dangerous_deserialization=True)
|
43 |
|
|
|
8 |
# Percorsi per il primo file ZIP
|
9 |
zip_path_m = "faiss_manual_index.zip" # File ZIP per l'indice manuale
|
10 |
extraction_dir_m = "./extracted_models/faiss_manual_index" # Sottocartella per estrazione manuale
|
11 |
+
testm_dir = extraction_dir_m # Cartella finale
|
12 |
|
13 |
# Percorsi per il secondo file ZIP
|
14 |
zip_path_p = "faiss_problems_index.zip" # File ZIP per l'indice problemi
|
15 |
extraction_dir_p = "./extracted_models/faiss_problems_index" # Sottocartella per estrazione problemi
|
16 |
+
testp_dir = extraction_dir_p # Cartella finale
|
17 |
|
18 |
# Estrai il primo file ZIP se non esiste già
|
19 |
+
if not os.path.exists(os.path.join(testm_dir, "index.faiss")):
|
20 |
with zipfile.ZipFile(zip_path_m, 'r') as zip_ref:
|
21 |
zip_ref.extractall(extraction_dir_m)
|
22 |
print(f"Indice Manuale estratto correttamente nella cartella {extraction_dir_m}")
|
|
|
24 |
print(f"Indice Manuale già presente in {testm_dir}")
|
25 |
|
26 |
# Estrai il secondo file ZIP se non esiste già
|
27 |
+
if not os.path.exists(os.path.join(testp_dir, "index.faiss")):
|
28 |
with zipfile.ZipFile(zip_path_p, 'r') as zip_ref:
|
29 |
zip_ref.extractall(extraction_dir_p)
|
30 |
print(f"Indice Problemi estratto correttamente nella cartella {extraction_dir_p}")
|
31 |
else:
|
32 |
print(f"Indice Problemi già presente in {testp_dir}")
|
33 |
|
|
|
|
|
34 |
# Carica il modello di embedding
|
35 |
embedding_model = HuggingFaceEmbeddings(model_name="sentence-transformers/LaBSE")
|
36 |
|
37 |
# Carica i vectorstore FAISS salvati
|
|
|
38 |
manual_vectorstore = FAISS.load_local(testm_dir, embedding_model, allow_dangerous_deserialization=True)
|
39 |
problems_vectorstore = FAISS.load_local(testp_dir, embedding_model, allow_dangerous_deserialization=True)
|
40 |
|