wangzerui commited on
Commit
a4c34d8
·
1 Parent(s): fa5cc48
Files changed (2) hide show
  1. __pycache__/app.cpython-311.pyc +0 -0
  2. app.py +17 -2
__pycache__/app.cpython-311.pyc CHANGED
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
 
app.py CHANGED
@@ -24,7 +24,13 @@ class GradioArchitectureApp:
24
  self.assistant = None
25
  self.current_user_id = None
26
  self.conversation_history = []
27
- self.state_manager = user_state_manager
 
 
 
 
 
 
28
 
29
  def initialize_user_session(self, user_identifier: str = None, api_key: str = None):
30
  """Initialize user session with persistent state"""
@@ -60,7 +66,10 @@ class GradioArchitectureApp:
60
  self.assistant = ArchitectureAssistant(effective_api_key, self.current_user_id)
61
 
62
  # Try to load their latest conversation
63
- history = self.state_manager.get_user_history(self.current_user_id)
 
 
 
64
 
65
  if history:
66
  # Load most recent conversation
@@ -213,6 +222,9 @@ class GradioArchitectureApp:
213
  if not user_id.strip():
214
  return "Please enter a User ID to view history."
215
 
 
 
 
216
  try:
217
  history = self.state_manager.get_user_history(user_id.strip())
218
 
@@ -263,6 +275,9 @@ class GradioArchitectureApp:
263
 
264
  def get_all_users_summary(self):
265
  """Get summary of all users"""
 
 
 
266
  try:
267
  users = self.state_manager.get_all_users()
268
 
 
24
  self.assistant = None
25
  self.current_user_id = None
26
  self.conversation_history = []
27
+
28
+ # Try to import state manager, but don't fail if it's not available
29
+ try:
30
+ from user_state_manager import user_state_manager
31
+ self.state_manager = user_state_manager
32
+ except ImportError:
33
+ self.state_manager = None
34
 
35
  def initialize_user_session(self, user_identifier: str = None, api_key: str = None):
36
  """Initialize user session with persistent state"""
 
66
  self.assistant = ArchitectureAssistant(effective_api_key, self.current_user_id)
67
 
68
  # Try to load their latest conversation
69
+ if self.state_manager:
70
+ history = self.state_manager.get_user_history(self.current_user_id)
71
+ else:
72
+ history = []
73
 
74
  if history:
75
  # Load most recent conversation
 
222
  if not user_id.strip():
223
  return "Please enter a User ID to view history."
224
 
225
+ if not self.state_manager:
226
+ return "❌ User history not available - state manager not initialized."
227
+
228
  try:
229
  history = self.state_manager.get_user_history(user_id.strip())
230
 
 
275
 
276
  def get_all_users_summary(self):
277
  """Get summary of all users"""
278
+ if not self.state_manager:
279
+ return "❌ User management not available - state manager not initialized."
280
+
281
  try:
282
  users = self.state_manager.get_all_users()
283