tecuhtli commited on
Commit
2b40817
·
verified ·
1 Parent(s): e870e13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -1,7 +1,7 @@
1
  #***************************************************************************
2
  #Importing Libraries
3
  #***************************************************************************
4
- import os, sys, warnings, torch, json, csv, warnings, joblib, uuid, re, unicodedata, numpy
5
  os.environ["TF_ENABLE_ONEDNN_OPTS"] = "0"
6
  import streamlit as st
7
  import datetime as dt
@@ -22,6 +22,24 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
22
  # Token privado desde variable de entorno
23
  HF_TOKEN = os.environ.get("HF_TOKEN")
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  #***************************************************************************
26
  # Sidebar controls for generation params
27
  #***************************************************************************
 
1
  #***************************************************************************
2
  #Importing Libraries
3
  #***************************************************************************
4
+ import os, sys, warnings, torch, json, csv, warnings, joblib, uuid, re, unicodedata, numpy, faiss
5
  os.environ["TF_ENABLE_ONEDNN_OPTS"] = "0"
6
  import streamlit as st
7
  import datetime as dt
 
22
  # Token privado desde variable de entorno
23
  HF_TOKEN = os.environ.get("HF_TOKEN")
24
 
25
+ #***************************************************************************
26
+ #Loading FAISS Vec DB
27
+ #***************************************************************************
28
+ REPO_ID = "hazutecuhtli/mori_faiss_full"
29
+
30
+ # Descarga de archivos privados
31
+ faiss_path = hf_hub_download(repo_id=REPO_ID, filename="mori.faiss", repo_type="dataset", token=TOKEN)
32
+ ids_path = hf_hub_download(repo_id=REPO_ID, filename="mori_ids.npy", repo_type="dataset", token=TOKEN)
33
+ meta_path = hf_hub_download(repo_id=REPO_ID, filename="mori_metas.json", repo_type="dataset", token=TOKEN)
34
+
35
+ # Carga de FAISS y metadatos
36
+ index = faiss.read_index(faiss_path)
37
+ ids = np.load(ids_path)
38
+ with open(meta_path, "r", encoding="utf-8") as f:
39
+ metas = json.load(f)
40
+
41
+ print(f"Índice cargado con {index.ntotal} vectores.")
42
+
43
  #***************************************************************************
44
  # Sidebar controls for generation params
45
  #***************************************************************************