adikwok commited on
Commit
52ad659
Β·
verified Β·
1 Parent(s): be2608d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -857,6 +857,21 @@ def get_topics_list() -> List[str]:
857
  print(f"❌ Error retrieving topics: {str(e)}")
858
  return ["All Topics"]
859
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
860
 
861
  # Define custom CSS for the Gradio interface
862
  custom_css = """
 
857
  print(f"❌ Error retrieving topics: {str(e)}")
858
  return ["All Topics"]
859
 
860
+ def send_message(user_input: str, topic_input: str) -> Tuple[str, str]:
861
+ """Handle sending a user message and getting AI response."""
862
+ try:
863
+ if not user_input.strip():
864
+ return "❌ Please enter a message", user_input
865
+ if not topic_input.strip():
866
+ return "❌ Please enter a topic", user_input
867
+
868
+ response, error = groq_with_memory(user_input, topic_input)
869
+ if error:
870
+ return f"❌ {error}", user_input
871
+ return response, "" # Clear user input after successful submission
872
+ except Exception as e:
873
+ return f"❌ Error processing message: {str(e)}", user_input
874
+
875
 
876
  # Define custom CSS for the Gradio interface
877
  custom_css = """