drguilhermeapolinario commited on
Commit
e11b77e
·
verified ·
1 Parent(s): 64055c4

Update views/rag_med.py

Browse files
Files changed (1) hide show
  1. views/rag_med.py +10 -6
views/rag_med.py CHANGED
@@ -37,12 +37,16 @@ with st.sidebar:
37
  st.rerun()
38
 
39
  # Carregando o índice FAISS e os dados armazenados
40
- index_file = "faiss_index.bin"
41
- data_file = "stored_data.pkl"
42
-
43
- index = faiss.read_index(index_file)
44
- with open(data_file, 'rb') as f:
45
- stored_data = pickle.load(f)
 
 
 
 
46
 
47
  # Inicialize o modelo de embedding
48
  model = SentenceTransformer("all-MiniLM-L6-v2")
 
37
  st.rerun()
38
 
39
  # Carregando o índice FAISS e os dados armazenados
40
+ @st.cache_resource
41
+ def load_faiss_index():
42
+ index_file = "faiss_index.bin"
43
+ data_file = "stored_data.pkl"
44
+ index = faiss.read_index(index_file)
45
+ with open(data_file, 'rb') as f:
46
+ stored_data = pickle.load(f)
47
+ return index, stored_data
48
+
49
+ index, stored_data = load_faiss_index()
50
 
51
  # Inicialize o modelo de embedding
52
  model = SentenceTransformer("all-MiniLM-L6-v2")