Hamza4100 commited on
Commit
a7c3e71
·
verified ·
1 Parent(s): 3632248

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -4
src/streamlit_app.py CHANGED
@@ -745,10 +745,15 @@ def render_ai_chat():
745
  if user_question:
746
  with st.spinner("Thinking..."):
747
  response = query_ai(user_question)
748
- st.session_state.chat_history.append({
749
- 'question': user_question,
750
- 'answer': response['answer']
751
- })
 
 
 
 
 
752
 
753
  # Display history
754
  if st.session_state.chat_history:
 
745
  if user_question:
746
  with st.spinner("Thinking..."):
747
  response = query_ai(user_question)
748
+ if response and 'answer' in response:
749
+ st.session_state.chat_history.append({
750
+ 'question': user_question,
751
+ 'answer': response['answer']
752
+ })
753
+ elif response and 'error' in response:
754
+ st.error(f"❌ {response['error']}")
755
+ else:
756
+ st.warning("⚠️ Unable to get AI response. Please try again.")
757
 
758
  # Display history
759
  if st.session_state.chat_history: