DrishtiSharma commited on
Commit
24d3f29
Β·
verified Β·
1 Parent(s): 2bc093c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -63,6 +63,8 @@ elif pdf_source == "Enter a PDF URL":
63
  st.session_state.processed = False # Reset processing
64
  else:
65
  st.error("❌ Failed to download PDF. Check the URL.")
 
 
66
 
67
  # Step 2: Process PDF and Create Vector Store (Only if Not Processed)
68
  if pdf_path and not st.session_state.processed:
@@ -74,7 +76,7 @@ if pdf_path and not st.session_state.processed:
74
  # Step 3: Chunking
75
  with st.spinner("Chunking the document..."):
76
  model_name = "nomic-ai/modernbert-embed-base"
77
- embedding_model = HuggingFaceEmbeddings(model_name=model_name, model_kwargs={'device': 'cpu'}, encode_kwargs= {'normalize_embeddings': False})
78
  text_splitter = SemanticChunker(embedding_model)
79
  documents = text_splitter.split_documents(docs)
80
  st.session_state.documents = documents
 
63
  st.session_state.processed = False # Reset processing
64
  else:
65
  st.error("❌ Failed to download PDF. Check the URL.")
66
+ except Exception as e: # <-- FIXED MISSING EXCEPTION HANDLING
67
+ st.error(f"Error downloading PDF: {e}")
68
 
69
  # Step 2: Process PDF and Create Vector Store (Only if Not Processed)
70
  if pdf_path and not st.session_state.processed:
 
76
  # Step 3: Chunking
77
  with st.spinner("Chunking the document..."):
78
  model_name = "nomic-ai/modernbert-embed-base"
79
+ embedding_model = HuggingFaceEmbeddings(model_name=model_name, model_kwargs={'device': 'cpu'}, encode_kwargs={'normalize_embeddings': False})
80
  text_splitter = SemanticChunker(embedding_model)
81
  documents = text_splitter.split_documents(docs)
82
  st.session_state.documents = documents