adikwok commited on
Commit
65622b7
·
verified ·
1 Parent(s): 52ad659

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -872,6 +872,19 @@ def send_message(user_input: str, topic_input: str) -> Tuple[str, str]:
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 = """
 
872
  except Exception as e:
873
  return f"❌ Error processing message: {str(e)}", user_input
874
 
875
+ def show_current_context() -> str:
876
+ """Show the current session's conversation context."""
877
+ try:
878
+ messages = storage.get_messages_by_session(storage.current_session_id)
879
+ if not messages:
880
+ return "No messages in the current session."
881
+ # Show up to the last 5 messages for brevity
882
+ context = "\n".join([f"{msg['role'].capitalize()}: {msg['content']}" for msg in messages[-5:]])
883
+ return f"Current Session Context (Last 5 Messages):\n{context}"
884
+ except Exception as e:
885
+ return f"❌ Error retrieving context: {str(e)}"
886
+
887
+
888
 
889
  # Define custom CSS for the Gradio interface
890
  custom_css = """