Dinesh310 commited on
Commit
4f5e730
·
verified ·
1 Parent(s): af62a2a

Update streamlit_app2.py

Browse files
Files changed (1) hide show
  1. streamlit_app2.py +25 -5
streamlit_app2.py CHANGED
@@ -28,22 +28,42 @@ with st.sidebar:
28
 
29
  if process_button and uploaded_files:
30
  with st.spinner("Processing PDFs..."):
31
- # Create temporary file paths to pass to your PDF Loader
32
  pdf_paths = []
 
33
  for uploaded_file in uploaded_files:
 
34
  with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp:
35
  tmp.write(uploaded_file.getvalue())
36
  pdf_paths.append(tmp.name)
37
 
38
- # Use your existing process_documents method
39
- st.session_state.rag_graph.process_documents(pdf_paths)
 
 
 
40
 
41
- # Clean up temp files
42
  for path in pdf_paths:
43
  os.remove(path)
44
-
45
  st.success("Documents Indexed Successfully!")
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  # --- Chat Interface ---
48
  # Display existing messages
49
  for message in st.session_state.messages:
 
28
 
29
  if process_button and uploaded_files:
30
  with st.spinner("Processing PDFs..."):
 
31
  pdf_paths = []
32
+ original_names = [] # <--- Add this
33
  for uploaded_file in uploaded_files:
34
+ original_names.append(uploaded_file.name) # <--- Capture real name
35
  with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp:
36
  tmp.write(uploaded_file.getvalue())
37
  pdf_paths.append(tmp.name)
38
 
39
+ # Pass BOTH the paths and the original names
40
+ st.session_state.rag_graph.process_documents(
41
+ pdf_paths,
42
+ original_names=original_names
43
+ )
44
 
 
45
  for path in pdf_paths:
46
  os.remove(path)
 
47
  st.success("Documents Indexed Successfully!")
48
 
49
+ # if process_button and uploaded_files:
50
+ # with st.spinner("Processing PDFs..."):
51
+ # # Create temporary file paths to pass to your PDF Loader
52
+ # pdf_paths = []
53
+ # for uploaded_file in uploaded_files:
54
+ # with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp:
55
+ # tmp.write(uploaded_file.getvalue())
56
+ # pdf_paths.append(tmp.name)
57
+
58
+ # # Use your existing process_documents method
59
+ # st.session_state.rag_graph.process_documents(pdf_paths)
60
+
61
+ # # Clean up temp files
62
+ # for path in pdf_paths:
63
+ # os.remove(path)
64
+
65
+ # st.success("Documents Indexed Successfully!")
66
+
67
  # --- Chat Interface ---
68
  # Display existing messages
69
  for message in st.session_state.messages: