arjunverma2004 commited on
Commit
a73f82b
·
verified ·
1 Parent(s): fde7654

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +8 -1
src/streamlit_app.py CHANGED
@@ -101,14 +101,21 @@ for message in st.session_state.messages:
101
  with st.chat_message(message["role"]):
102
  st.markdown(message["content"])
103
 
 
104
  if prompt := st.chat_input("Ask about fee deadlines, scholarships, etc."):
 
105
  st.session_state.messages.append({"role": "user", "content": prompt})
106
  with st.chat_message("user"):
107
  st.markdown(prompt)
108
 
 
109
  with st.chat_message("assistant"):
110
- with st.spinner("Searching Notion..."):
 
111
  context = get_context(prompt)
 
112
  response = generate_response(prompt, context)
 
113
  st.markdown(response)
 
114
  st.session_state.messages.append({"role": "assistant", "content": response})
 
101
  with st.chat_message(message["role"]):
102
  st.markdown(message["content"])
103
 
104
+ # Main chat input logic
105
  if prompt := st.chat_input("Ask about fee deadlines, scholarships, etc."):
106
+ # Add user message to session state and display it
107
  st.session_state.messages.append({"role": "user", "content": prompt})
108
  with st.chat_message("user"):
109
  st.markdown(prompt)
110
 
111
+ # Get and display bot response
112
  with st.chat_message("assistant"):
113
+ with st.spinner("Thinking..."):
114
+ # 1. Retrieve context
115
  context = get_context(prompt)
116
+ # 2. Generate response
117
  response = generate_response(prompt, context)
118
+ # 3. Display response INSIDE the bubble
119
  st.markdown(response)
120
+ # 4. Add the response to the history for the next re-run
121
  st.session_state.messages.append({"role": "assistant", "content": response})