Anirudh Esthuri commited on
Commit
ef68cd9
Β·
1 Parent(s): 42f0aac

Add comprehensive error handling and debug output to diagnose blank screen

Browse files
Files changed (1) hide show
  1. app.py +45 -14
app.py CHANGED
@@ -60,7 +60,10 @@ def rewrite_message(
60
  # ──────────────────────────────────────────────────────────────
61
  # Page setup & CSS
62
  # ──────────────────────────────────────────────────────────────
63
- st.set_page_config(page_title="MemMachine Chatbot", layout="wide")
 
 
 
64
 
65
  # Show import errors if any
66
  if not IMPORTS_SUCCESSFUL:
@@ -70,6 +73,9 @@ if not IMPORTS_SUCCESSFUL:
70
  st.code(IMPORT_TRACEBACK)
71
  st.stop()
72
 
 
 
 
73
  try:
74
  with open("./styles.css") as f:
75
  st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
@@ -80,20 +86,40 @@ except FileNotFoundError:
80
  # ──────────────────────────────────────────────────────────────
81
  # Sidebar
82
  # ──────────────────────────────────────────────────────────────
83
- with st.sidebar:
84
- try:
85
- st.image("./assets/memmachine_logo.png", use_container_width=True)
86
- except FileNotFoundError:
87
- st.markdown("### MemMachine")
88
-
89
- st.markdown("#### Choose Model")
90
 
91
- model_id = st.selectbox(
92
- "Choose Model", MODEL_CHOICES, index=0, label_visibility="collapsed"
93
- )
94
- provider = MODEL_TO_PROVIDER[model_id]
95
- set_model(model_id)
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  st.markdown("#### Choose user persona")
98
  selected_persona = st.selectbox(
99
  "Choose user persona",
@@ -159,7 +185,12 @@ def append_user_turn(msgs: list[dict], new_user_msg: str) -> list[dict]:
159
  # ──────────────────────────────────────────────────────────────
160
  # Title
161
  # ──────────────────────────────────────────────────────────────
162
- st.title("MemMachine Chatbot")
 
 
 
 
 
163
 
164
  # ──────────────────────────────────────────────────────────────
165
  # Chat logic
 
60
  # ──────────────────────────────────────────────────────────────
61
  # Page setup & CSS
62
  # ──────────────────────────────────────────────────────────────
63
+ try:
64
+ st.set_page_config(page_title="MemMachine Chatbot", layout="wide")
65
+ except Exception as e:
66
+ st.error(f"Failed to set page config: {e}")
67
 
68
  # Show import errors if any
69
  if not IMPORTS_SUCCESSFUL:
 
73
  st.code(IMPORT_TRACEBACK)
74
  st.stop()
75
 
76
+ # Debug: Show that app is loading
77
+ st.write("πŸš€ App is loading...")
78
+
79
  try:
80
  with open("./styles.css") as f:
81
  st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
 
86
  # ──────────────────────────────────────────────────────────────
87
  # Sidebar
88
  # ──────────────────────────────────────────────────────────────
89
+ try:
90
+ with st.sidebar:
91
+ try:
92
+ st.image("./assets/memmachine_logo.png", use_container_width=True)
93
+ except (FileNotFoundError, Exception) as e:
94
+ st.markdown("### MemMachine")
 
95
 
96
+ st.markdown("#### Choose Model")
 
 
 
 
97
 
98
+ try:
99
+ model_id = st.selectbox(
100
+ "Choose Model", MODEL_CHOICES, index=0, label_visibility="collapsed"
101
+ )
102
+ provider = MODEL_TO_PROVIDER[model_id]
103
+ set_model(model_id)
104
+ except Exception as e:
105
+ st.error(f"Error in model selection: {e}")
106
+ model_id = MODEL_CHOICES[0] if MODEL_CHOICES else "gpt-4.1-mini"
107
+ provider = MODEL_TO_PROVIDER.get(model_id, "openai")
108
+ set_model(model_id)
109
+ except Exception as e:
110
+ st.error(f"Error initializing sidebar: {e}")
111
+ import traceback
112
+ st.code(traceback.format_exc())
113
+ # Set defaults
114
+ model_id = MODEL_CHOICES[0] if MODEL_CHOICES else "gpt-4.1-mini"
115
+ provider = MODEL_TO_PROVIDER.get(model_id, "openai")
116
+ selected_persona = "Charlie"
117
+ persona_name = "Charlie"
118
+ skip_rewrite = False
119
+ compare_personas = False
120
+ show_rationale = False
121
+ else:
122
+ # Continue with sidebar if no exception
123
  st.markdown("#### Choose user persona")
124
  selected_persona = st.selectbox(
125
  "Choose user persona",
 
185
  # ──────────────────────────────────────────────────────────────
186
  # Title
187
  # ──────────────────────────────────────────────────────────────
188
+ try:
189
+ st.title("MemMachine Chatbot")
190
+ except Exception as e:
191
+ st.error(f"Error rendering title: {e}")
192
+ import traceback
193
+ st.code(traceback.format_exc())
194
 
195
  # ──────────────────────────────────────────────────────────────
196
  # Chat logic