ImranzamanML commited on
Commit
a03a6c3
·
verified ·
1 Parent(s): 27d84dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -9,7 +9,6 @@ from langchain.chains.question_answering import load_qa_chain
9
  from langchain_google_genai import GoogleGenerativeAIEmbeddings
10
  from langchain.text_splitter import RecursiveCharacterTextSplitter
11
 
12
-
13
  def process_pdf_files(pdf_files, embedding_model_name):
14
  text = ""
15
  for pdf in pdf_files:
@@ -64,10 +63,6 @@ def main():
64
 
65
  st.subheader("Upload your PDF Files")
66
  pdf_files = st.file_uploader("Upload your files", accept_multiple_files=True)
67
- if st.button("Submit data") and pdf_files:
68
- with st.spinner("Processing the data . . ."):
69
- process_pdf_files(pdf_files, embedding_model_name)
70
- st.success("Files submitted successfully")
71
 
72
  st.sidebar.header("Configuration")
73
  api_key = st.sidebar.text_input("Google API Key:", type="password")
@@ -90,6 +85,14 @@ def main():
90
  else:
91
  embedding_model_name = selected_embedding_model
92
 
 
 
 
 
 
 
 
 
93
  if api_key:
94
  genai.configure(api_key=api_key)
95
 
@@ -137,4 +140,4 @@ def get_base64_of_image(image_path):
137
  return base64_str
138
 
139
  if __name__ == "__main__":
140
- main()
 
9
  from langchain_google_genai import GoogleGenerativeAIEmbeddings
10
  from langchain.text_splitter import RecursiveCharacterTextSplitter
11
 
 
12
  def process_pdf_files(pdf_files, embedding_model_name):
13
  text = ""
14
  for pdf in pdf_files:
 
63
 
64
  st.subheader("Upload your PDF Files")
65
  pdf_files = st.file_uploader("Upload your files", accept_multiple_files=True)
 
 
 
 
66
 
67
  st.sidebar.header("Configuration")
68
  api_key = st.sidebar.text_input("Google API Key:", type="password")
 
85
  else:
86
  embedding_model_name = selected_embedding_model
87
 
88
+ if st.button("Submit data") and pdf_files:
89
+ if embedding_model_name:
90
+ with st.spinner("Processing the data . . ."):
91
+ process_pdf_files(pdf_files, embedding_model_name)
92
+ st.success("Files submitted successfully")
93
+ else:
94
+ st.warning("Please select or enter an embedding model.")
95
+
96
  if api_key:
97
  genai.configure(api_key=api_key)
98
 
 
140
  return base64_str
141
 
142
  if __name__ == "__main__":
143
+ main()