suriya7 commited on
Commit
1da8d89
1 Parent(s): ea79d95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  import os
3
  from streamlit_chat import message
4
  from PyPDF2 import PdfReader
 
5
  import google.generativeai as genai
6
  from langchain.prompts import PromptTemplate
7
  from langchain import LLMChain
@@ -103,11 +104,19 @@ with st.sidebar:
103
  uploaded_file = st.file_uploader("Upload your PDF Files and Click on the Submit & Process Button", accept_multiple_files=True)
104
  uploaded_url = st.text_area("please upload an url..")
105
  if st.button("Submit & Process"):
106
- if uploaded_file or uploaded_url:
107
  with st.spinner("Processing..."):
108
- st.session_state["docs"] += get_pdf_text(uploaded_file)
109
- st.session_state["docs"] += get_url_text(uploaded_url)
110
- st.success("Done")
 
 
 
 
 
 
 
 
111
 
112
  # Create containers for chat history and user input
113
  response_container = st.container()
 
2
  import os
3
  from streamlit_chat import message
4
  from PyPDF2 import PdfReader
5
+ import bs4
6
  import google.generativeai as genai
7
  from langchain.prompts import PromptTemplate
8
  from langchain import LLMChain
 
104
  uploaded_file = st.file_uploader("Upload your PDF Files and Click on the Submit & Process Button", accept_multiple_files=True)
105
  uploaded_url = st.text_area("please upload an url..")
106
  if st.button("Submit & Process"):
107
+ if uploaded_files or uploaded_url:
108
  with st.spinner("Processing..."):
109
+ if uploaded_files:
110
+ pdf_text = get_pdf_text(uploaded_files)
111
+ st.session_state["docs"] = (st.session_state.get("docs", "") + pdf_text).strip()
112
+
113
+ if uploaded_url:
114
+ url_text = get_url_text(uploaded_url)
115
+ st.session_state["docs"] = (st.session_state.get("docs", "") + url_text).strip()
116
+
117
+ st.success("Processing complete!")
118
+ else:
119
+ st.error("Please upload at least one PDF file or provide a URL.")
120
 
121
  # Create containers for chat history and user input
122
  response_container = st.container()