euracle commited on
Commit
b241369
Β·
verified Β·
1 Parent(s): 75da36d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -26
app.py CHANGED
@@ -191,11 +191,29 @@ else:
191
  documents = st.session_state["documents"]
192
  vector_db = st.session_state["vector_db"]
193
 
194
- end_time = time.time()
195
- print(f"Loading and processing PDFs & vector database took {end_time - start_time:.4f} seconds")
196
-
197
- start_time = time.time()
198
  retriever = vector_db.as_retriever()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
 
200
  prompt_template = """As an expert organic farming consultant with specialization in Agro-Homeopathy, analyze the following context and question to provide a clear, structured response.
201
  Context: {context}
@@ -286,28 +304,6 @@ fallback_chain = LLMChain(
286
  memory=st.session_state.conversation_memory
287
  )
288
 
289
- with st.sidebar:
290
- st.title("Conversation History")
291
-
292
- if st.button("New Session πŸ”„"):
293
- # Clear all conversation related session states
294
- st.session_state.messages = []
295
- st.session_state.messages.append({
296
- "role": "assistant",
297
- "content": "πŸ‘‹ Hello! I'm Dr. Radha, your AI-powered Organic Farming Consultant. How can I assist you today?"
298
- })
299
- st.session_state.conversation_memory.clear()
300
- st.session_state.session_id = str(uuid.uuid4())
301
- st.rerun()
302
- # Display conversation history
303
- st.subheader("Previous Conversations")
304
- for message in st.session_state.messages[1:]: # Skip the initial greeting
305
- if message["role"] == "user":
306
- st.text("You:")
307
- st.text_area("", message["content"], height=50, disabled=True, key=f"hist_{uuid.uuid4()}")
308
- else:
309
- st.text("Dr. Radha:")
310
- st.text_area("", message["content"], height=100, disabled=True, key=f"hist_{uuid.uuid4()}")
311
 
312
  # Replace your existing chat container and form section with this:
313
  chat_container = st.container()
 
191
  documents = st.session_state["documents"]
192
  vector_db = st.session_state["vector_db"]
193
 
 
 
 
 
194
  retriever = vector_db.as_retriever()
195
+ with st.sidebar:
196
+ st.title("Conversation History")
197
+
198
+ if st.button("New Session πŸ”„"):
199
+ # Clear all conversation related session states
200
+ st.session_state.messages = []
201
+ st.session_state.messages.append({
202
+ "role": "assistant",
203
+ "content": "πŸ‘‹ Hello! I'm Dr. Radha, your AI-powered Organic Farming Consultant. How can I assist you today?"
204
+ })
205
+ st.session_state.conversation_memory.clear()
206
+ st.session_state.session_id = str(uuid.uuid4())
207
+ st.rerun()
208
+ # Display conversation history
209
+ st.subheader("Previous Conversations")
210
+ for message in st.session_state.messages[1:]: # Skip the initial greeting
211
+ if message["role"] == "user":
212
+ st.text("You:")
213
+ st.text_area("", message["content"], height=50, disabled=True, key=f"hist_{uuid.uuid4()}")
214
+ else:
215
+ st.text("Dr. Radha:")
216
+ st.text_area("", message["content"], height=100, disabled=True, key=f"hist_{uuid.uuid4()}")
217
 
218
  prompt_template = """As an expert organic farming consultant with specialization in Agro-Homeopathy, analyze the following context and question to provide a clear, structured response.
219
  Context: {context}
 
304
  memory=st.session_state.conversation_memory
305
  )
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
 
308
  # Replace your existing chat container and form section with this:
309
  chat_container = st.container()