Spaces:
Sleeping
Sleeping
fix: error in faiss
Browse files
app.py
CHANGED
@@ -25,6 +25,17 @@ def fetch_arxiv_papers(query, max_results=5):
|
|
25 |
|
26 |
# Load FAISS index
|
27 |
def load_faiss_index(index_file="faiss_index.index"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
return faiss.read_index(index_file)
|
29 |
|
30 |
# RAG Pipeline
|
|
|
25 |
|
26 |
# Load FAISS index
|
27 |
def load_faiss_index(index_file="faiss_index.index"):
|
28 |
+
import os
|
29 |
+
if not os.path.exists(index_file):
|
30 |
+
st.warning("FAISS index not found. Building index from scratch...")
|
31 |
+
# Import the build function from the other file
|
32 |
+
import faiss_index_index
|
33 |
+
|
34 |
+
# Fetch some initial papers to build the index
|
35 |
+
initial_papers = faiss_index_index.fetch_arxiv_papers("autism research", max_results=100)
|
36 |
+
faiss_index_index.build_faiss_index(initial_papers, index_file)
|
37 |
+
st.success("FAISS index built successfully!")
|
38 |
+
|
39 |
return faiss.read_index(index_file)
|
40 |
|
41 |
# RAG Pipeline
|