Sharal commited on
Commit
4ba3627
·
verified ·
1 Parent(s): 1376891

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -36
app.py CHANGED
@@ -150,39 +150,4 @@ def main():
150
  st.sidebar.markdown("### Select Large Language Model (LLM)")
151
  llm_option = st.sidebar.radio("Available LLMs", list_llm_simple)
152
 
153
- if st.sidebar.button("Initialize Question Answering Chatbot"):
154
- with st.spinner("Initializing QA chatbot..."):
155
- qa_chain, llm_message = initialize_LLM(list_llm_simple.index(llm_option), st.session_state['vector_db'])
156
- st.session_state['qa_chain'] = qa_chain
157
- st.sidebar.success(llm_message)
158
-
159
- st.title("Chat with your Document")
160
-
161
- if st.session_state['qa_chain']:
162
- st.markdown("### Chatbot Response")
163
-
164
- # Display the chat history in a chat-like interface
165
- for i, (user_msg, bot_msg) in enumerate(st.session_state['chat_history']):
166
- st.markdown(f"**User:** {user_msg}")
167
- st.markdown(f"**Assistant:** {bot_msg}")
168
-
169
- st.markdown("### Relevant context from the source document")
170
-
171
- with st.expander("Relevant context from the source document"):
172
- if 'sources' in st.session_state:
173
- for i, source in enumerate(st.session_state['sources']):
174
- st.text_area(f"Source {i + 1} - Page {source['page']}", value=source["content"], height=100)
175
-
176
- with st.form(key="question_form"):
177
- message = st.text_input("Ask a question", key="message")
178
- submit_button = st.form_submit_button(label="Submit")
179
-
180
- if submit_button:
181
- with st.spinner("Generating response..."):
182
- qa_chain, chat_history, response_answer, sources = conversation(st.session_state['qa_chain'], message, st.session_state['chat_history'])
183
- st.session_state['qa_chain'] = qa_chain
184
- st.session_state['chat_history'] = chat_history
185
- st.session_state['sources'] = sources
186
-
187
- if __name__ == "__main__":
188
- main()
 
150
  st.sidebar.markdown("### Select Large Language Model (LLM)")
151
  llm_option = st.sidebar.radio("Available LLMs", list_llm_simple)
152
 
153
+ if