nishantgaurav23 commited on
Commit
ba2d700
Β·
verified Β·
1 Parent(s): 9b8a800

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -24
app.py CHANGED
@@ -735,24 +735,24 @@ def main():
735
  </style>
736
  """, unsafe_allow_html=True)
737
 
738
- # Header section with unique keys
739
- st.markdown("<h1 class='main-title'>πŸ† The Sport Chatbot</h1>", unsafe_allow_html=True, key="title")
740
- st.markdown("<h3 class='sub-title'>Using ESPN API</h3>", unsafe_allow_html=True, key="subtitle")
741
  st.markdown("""
742
  <p class='description'>
743
  Hey there! πŸ‘‹ I can help you with information on Ice Hockey, Baseball, American Football, Soccer, and Basketball.
744
  With access to the ESPN API, I'm up to date with the latest details for these sports up until October 2024.
745
  </p>
746
- """, unsafe_allow_html=True, key="desc1")
747
 
748
  st.markdown("""
749
  <p class='description'>
750
  Got any general questions? Feel free to askβ€”I'll do my best to provide answers based on the information I've been trained on!
751
  </p>
752
- """, unsafe_allow_html=True, key="desc2")
753
 
754
  # Add spacing
755
- st.markdown("<br>", unsafe_allow_html=True, key="spacing1")
756
 
757
  # Initialize the pipeline with better error handling
758
  if 'rag' not in st.session_state:
@@ -762,7 +762,7 @@ def main():
762
  logging.info("Pipeline initialized successfully")
763
  except Exception as e:
764
  logging.error(f"Pipeline initialization error: {str(e)}")
765
- st.error("Failed to initialize the system. Please check the logs.", key="init_error")
766
  st.stop()
767
  return
768
 
@@ -795,29 +795,23 @@ def main():
795
  # Log error details
796
  logging.error(f"Query processing error: {str(e)}")
797
  logging.error("Full error details: ", exc_info=True)
798
- response_placeholder.warning(
799
- "Unable to process your question. Please try again.",
800
- key="query_error"
801
- )
802
  else:
803
- st.warning("Please enter a question!", key="empty_query_warning")
804
 
805
- # Footer with unique keys
806
- st.markdown("<br><br>", unsafe_allow_html=True, key="spacing2")
807
- st.markdown("---", key="divider")
808
  st.markdown("""
809
  <p style='text-align: center; color: #666666; padding: 1rem 0;'>
810
  Powered by ESPN Data & Mistral AI πŸš€
811
  </p>
812
- """, unsafe_allow_html=True, key="footer")
813
 
814
  except Exception as e:
815
  logging.error(f"Application error: {str(e)}")
816
  logging.error("Full error details: ", exc_info=True)
817
- st.error(
818
- "An unexpected error occurred. Please check the logs and try again.",
819
- key="main_error"
820
- )
821
 
822
  if __name__ == "__main__":
823
  # Configure logging
@@ -831,7 +825,4 @@ if __name__ == "__main__":
831
  except Exception as e:
832
  logging.error(f"Fatal error: {str(e)}")
833
  logging.error("Full error details: ", exc_info=True)
834
- st.error(
835
- "A fatal error occurred. Please check the logs and try again.",
836
- key="fatal_error"
837
- )
 
735
  </style>
736
  """, unsafe_allow_html=True)
737
 
738
+ # Header section
739
+ st.markdown("<h1 class='main-title'>πŸ† The Sport Chatbot</h1>", unsafe_allow_html=True)
740
+ st.markdown("<h3 class='sub-title'>Using ESPN API</h3>", unsafe_allow_html=True)
741
  st.markdown("""
742
  <p class='description'>
743
  Hey there! πŸ‘‹ I can help you with information on Ice Hockey, Baseball, American Football, Soccer, and Basketball.
744
  With access to the ESPN API, I'm up to date with the latest details for these sports up until October 2024.
745
  </p>
746
+ """, unsafe_allow_html=True)
747
 
748
  st.markdown("""
749
  <p class='description'>
750
  Got any general questions? Feel free to askβ€”I'll do my best to provide answers based on the information I've been trained on!
751
  </p>
752
+ """, unsafe_allow_html=True)
753
 
754
  # Add spacing
755
+ st.markdown("<br>", unsafe_allow_html=True)
756
 
757
  # Initialize the pipeline with better error handling
758
  if 'rag' not in st.session_state:
 
762
  logging.info("Pipeline initialized successfully")
763
  except Exception as e:
764
  logging.error(f"Pipeline initialization error: {str(e)}")
765
+ st.error("Failed to initialize the system. Please check the logs.")
766
  st.stop()
767
  return
768
 
 
795
  # Log error details
796
  logging.error(f"Query processing error: {str(e)}")
797
  logging.error("Full error details: ", exc_info=True)
798
+ response_placeholder.warning("Unable to process your question. Please try again.")
 
 
 
799
  else:
800
+ st.warning("Please enter a question!")
801
 
802
+ # Footer
803
+ st.markdown("<br><br>", unsafe_allow_html=True)
804
+ st.markdown("---")
805
  st.markdown("""
806
  <p style='text-align: center; color: #666666; padding: 1rem 0;'>
807
  Powered by ESPN Data & Mistral AI πŸš€
808
  </p>
809
+ """, unsafe_allow_html=True)
810
 
811
  except Exception as e:
812
  logging.error(f"Application error: {str(e)}")
813
  logging.error("Full error details: ", exc_info=True)
814
+ st.error("An unexpected error occurred. Please check the logs and try again.")
 
 
 
815
 
816
  if __name__ == "__main__":
817
  # Configure logging
 
825
  except Exception as e:
826
  logging.error(f"Fatal error: {str(e)}")
827
  logging.error("Full error details: ", exc_info=True)
828
+ st.error("A fatal error occurred. Please check the logs and try again.")