Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -706,32 +706,6 @@ def ask_question(question, temperature, top_p, repetition_penalty, web_search, g
|
|
706 |
|
707 |
return answer
|
708 |
|
709 |
-
def update_vectors(files, use_recursive_splitter):
|
710 |
-
if not files:
|
711 |
-
return "Please upload at least one PDF file."
|
712 |
-
|
713 |
-
embed = get_embeddings()
|
714 |
-
total_chunks = 0
|
715 |
-
|
716 |
-
all_data = []
|
717 |
-
for file in files:
|
718 |
-
if use_recursive_splitter:
|
719 |
-
data = load_and_split_document_recursive(file)
|
720 |
-
else:
|
721 |
-
data = load_and_split_document_basic(file)
|
722 |
-
all_data.extend(data)
|
723 |
-
total_chunks += len(data)
|
724 |
-
|
725 |
-
if os.path.exists("faiss_database"):
|
726 |
-
database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)
|
727 |
-
database.add_documents(all_data)
|
728 |
-
else:
|
729 |
-
database = FAISS.from_documents(all_data, embed)
|
730 |
-
|
731 |
-
database.save_local("faiss_database")
|
732 |
-
|
733 |
-
return f"Vector store updated successfully. Processed {total_chunks} chunks from {len(files)} files."
|
734 |
-
|
735 |
def extract_db_to_excel():
|
736 |
embed = get_embeddings()
|
737 |
database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)
|
|
|
706 |
|
707 |
return answer
|
708 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
709 |
def extract_db_to_excel():
|
710 |
embed = get_embeddings()
|
711 |
database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)
|