Sharal commited on
Commit
ecbab86
·
verified ·
1 Parent(s): a1d1670

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -128,16 +128,16 @@ def conversation(qa_chain, message, history):
128
  return qa_chain, history, "", 0, "", 0, "", 0
129
 
130
  def main():
131
- st.title("PDF Chatbot")
132
 
133
- st.markdown("### Step 1 - Upload PDF documents and Initialize RAG pipeline")
134
- uploaded_files = st.file_uploader("Upload PDF documents", type="pdf", accept_multiple_files=True)
135
 
136
  if uploaded_files:
137
- if st.button("Create vector database"):
138
  with st.spinner("Creating vector database..."):
139
  vector_db, db_message = initialize_database(uploaded_files)
140
- st.success(db_message)
141
  st.session_state['vector_db'] = vector_db
142
 
143
  if 'vector_db' not in st.session_state:
@@ -146,16 +146,17 @@ def main():
146
  if 'qa_chain' not in st.session_state:
147
  st.session_state['qa_chain'] = None
148
 
149
- st.markdown("### Select Large Language Model (LLM) and input parameters")
150
- llm_option = st.radio("Available LLMs", list_llm_simple)
151
 
152
- if st.button("Initialize Question Answering Chatbot"):
153
  with st.spinner("Initializing QA chatbot..."):
154
  qa_chain, llm_message = initialize_LLM(list_llm_simple.index(llm_option), st.session_state['vector_db'])
155
  st.session_state['qa_chain'] = qa_chain
156
- st.success(llm_message)
 
 
157
 
158
- st.markdown("### Step 2 - Chat with your Document")
159
  if st.session_state['qa_chain']:
160
  history = []
161
  message = st.text_input("Ask a question")
 
128
  return qa_chain, history, "", 0, "", 0, "", 0
129
 
130
  def main():
131
+ st.sidebar.title("PDF Chatbot")
132
 
133
+ st.sidebar.markdown("### Step 1 - Upload PDF documents and Initialize RAG pipeline")
134
+ uploaded_files = st.sidebar.file_uploader("Upload PDF documents", type="pdf", accept_multiple_files=True)
135
 
136
  if uploaded_files:
137
+ if st.sidebar.button("Create vector database"):
138
  with st.spinner("Creating vector database..."):
139
  vector_db, db_message = initialize_database(uploaded_files)
140
+ st.sidebar.success(db_message)
141
  st.session_state['vector_db'] = vector_db
142
 
143
  if 'vector_db' not in st.session_state:
 
146
  if 'qa_chain' not in st.session_state:
147
  st.session_state['qa_chain'] = None
148
 
149
+ st.sidebar.markdown("### Select Large Language Model (LLM) and input parameters")
150
+ llm_option = st.sidebar.radio("Available LLMs", list_llm_simple)
151
 
152
+ if st.sidebar.button("Initialize Question Answering Chatbot"):
153
  with st.spinner("Initializing QA chatbot..."):
154
  qa_chain, llm_message = initialize_LLM(list_llm_simple.index(llm_option), st.session_state['vector_db'])
155
  st.session_state['qa_chain'] = qa_chain
156
+ st.sidebar.success(llm_message)
157
+
158
+ st.title("Chat with your Document")
159
 
 
160
  if st.session_state['qa_chain']:
161
  history = []
162
  message = st.text_input("Ask a question")