Docfile commited on
Commit
be48fa7
·
verified ·
1 Parent(s): 9a09dcf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -64,11 +64,8 @@ def load_and_index_pdf(pdf_path):
64
  logging.info(f"Loading PDF document from: {pdf_path}")
65
  documents = SimpleDirectoryReader(input_files=[pdf_path]).load_data()
66
  if documents:
67
- logging.info("Creating semantic splitter")
68
- node_parser = create_semantic_splitter_node_parser()
69
- nodes = node_parser.get_nodes_from_documents(documents)
70
  logging.info("Creating vector store index")
71
- index = VectorStoreIndex(nodes=nodes)
72
  return index
73
  else:
74
  logging.warning("No documents found in the PDF")
@@ -91,10 +88,8 @@ def create_rag_pipeline(index):
91
  logging.info("Initializing RAG Pipeline components")
92
  # setup retriever
93
 
94
- retriever = VectorStoreIndex(
95
- index.nodes,
96
- ).as_retriever(similarity_top_k=5)
97
-
98
 
99
  # setup query transformer
100
  hyde_query_transform = HyDEQueryTransform(llm=Settings.llm)
 
64
  logging.info(f"Loading PDF document from: {pdf_path}")
65
  documents = SimpleDirectoryReader(input_files=[pdf_path]).load_data()
66
  if documents:
 
 
 
67
  logging.info("Creating vector store index")
68
+ index = VectorStoreIndex.from_documents(documents, node_parser=create_semantic_splitter_node_parser())
69
  return index
70
  else:
71
  logging.warning("No documents found in the PDF")
 
88
  logging.info("Initializing RAG Pipeline components")
89
  # setup retriever
90
 
91
+ retriever = index.as_retriever(similarity_top_k=5)
92
+
 
 
93
 
94
  # setup query transformer
95
  hyde_query_transform = HyDEQueryTransform(llm=Settings.llm)