Veda0718 commited on
Commit
131f2e6
·
verified ·
1 Parent(s): 4be6f9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -112,6 +112,11 @@ st.title("Medical Chatbot")
112
  if "history" not in st.session_state:
113
  st.session_state.history = []
114
 
 
 
 
 
 
115
  user_input = st.text_input("Ask a question:", key="input")
116
 
117
  if st.button("Submit"):
@@ -119,8 +124,15 @@ if st.button("Submit"):
119
  result = st.session_state.qa_chain(user_input)
120
  answer = result["result"]
121
  st.session_state.history.append({"question": user_input, "answer": answer})
122
-
123
- # Display chat history using streamlit-chat
124
- for i, chat in enumerate(st.session_state.history):
125
- message(chat['question'], is_user=True, key=f"user_{i}")
126
- message(chat['answer'], key=f"bot_{i}")
 
 
 
 
 
 
 
 
112
  if "history" not in st.session_state:
113
  st.session_state.history = []
114
 
115
+ # Display chat history using streamlit-chat
116
+ for i, chat in enumerate(st.session_state.history):
117
+ message(chat['question'], is_user=True, key=f"user_{i}")
118
+ message(chat['answer'], key=f"bot_{i}")
119
+
120
  user_input = st.text_input("Ask a question:", key="input")
121
 
122
  if st.button("Submit"):
 
124
  result = st.session_state.qa_chain(user_input)
125
  answer = result["result"]
126
  st.session_state.history.append({"question": user_input, "answer": answer})
127
+ # Clear input text after submission
128
+ st.session_state.input = ""
129
+
130
+ # Scroll to the bottom to display the latest message
131
+ st.markdown(
132
+ """
133
+ <script>
134
+ window.scrollTo(0, document.body.scrollHeight);
135
+ </script>
136
+ """,
137
+ unsafe_allow_html=True,
138
+ )