Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,37 @@
|
|
2 |
import gradio as gr
|
3 |
from langchain.vectorstores import FAISS
|
4 |
from langchain.embeddings import HuggingFaceEmbeddings
|
|
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
# Carica il modello di embedding
|
7 |
embedding_model = HuggingFaceEmbeddings(model_name="sentence-transformers/LaBSE")
|
8 |
|
|
|
2 |
import gradio as gr
|
3 |
from langchain.vectorstores import FAISS
|
4 |
from langchain.embeddings import HuggingFaceEmbeddings
|
5 |
+
import zipfile
|
6 |
|
7 |
+
|
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/manual_index" # Sottocartella per estrazione manuale
|
11 |
+
testm_dir = "./extracted_models/manual_index/faiss_manual_index" # 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/problems_index" # Sottocartella per estrazione problemi
|
16 |
+
testp_dir = "./extracted_models/problems_index/faiss_problems_index" # Cartella finale
|
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}")
|
23 |
+
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 |
|