lekkalar commited on
Commit
67fa155
·
1 Parent(s): d961ca8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -27,13 +27,16 @@ def load_pdf_and_generate_embeddings(pdf_doc, open_ai_key, relevant_pages='all')
27
  pages_to_be_loaded = pages.copy()
28
  else:
29
  page_numbers = relevant_pages.split(",")
30
- for page_number in page_numbers:
31
- pageIndex = int(page_number)-1
32
- if pageIndex >=0 and pageIndex <len(pages):
33
- pages_to_be_loaded.append(pages[pageIndex])
34
- #In the scenario where none of the page numbers supplied exist in the PDF, we will revert to using the entire PDF.
35
- if len(pages_to_be_loaded) ==0:
36
- pages_to_be_loaded = pages.copy()
 
 
 
37
 
38
  #To create a vector store, we use the Chroma class, which takes the documents (pages in our case) and the embeddings instance
39
  vectordb = Chroma.from_documents(pages_to_be_loaded, embedding=embeddings)
 
27
  pages_to_be_loaded = pages.copy()
28
  else:
29
  page_numbers = relevant_pages.split(",")
30
+ if len(page_numbers) != 0:
31
+ for page_number in page_numbers:
32
+ pageIndex = int(page_number)-1
33
+ if pageIndex >=0 and pageIndex <len(pages):
34
+ pages_to_be_loaded.append(pages[pageIndex])
35
+ #In the scenario where none of the page numbers supplied exist in the PDF, we will revert to using the entire PDF.
36
+ if len(pages_to_be_loaded) ==0:
37
+ pages_to_be_loaded = pages.copy()
38
+ else:
39
+ pages_to_be_loaded = pages.copy()
40
 
41
  #To create a vector store, we use the Chroma class, which takes the documents (pages in our case) and the embeddings instance
42
  vectordb = Chroma.from_documents(pages_to_be_loaded, embedding=embeddings)