anderson-ufrj commited on
Commit
8a2c2ec
·
1 Parent(s): 78c6734

fix: add detailed diagnostics for Drummond initialization

Browse files

- Log MARITACA_API_KEY availability check
- Add detailed error logging with traceback
- Show final initialization status
- Help diagnose why Drummond falls back to maintenance mode

Files changed (2) hide show
  1. check_drummond_status.py +17 -0
  2. src/api/routes/chat.py +15 -0
check_drummond_status.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Check Drummond debug status"""
3
+ import requests
4
+ import json
5
+
6
+ url = "https://neural-thinker-cidadao-ai-backend.hf.space/api/v1/chat/debug/drummond-status"
7
+
8
+ try:
9
+ response = requests.get(url)
10
+ print(f"Status: {response.status_code}")
11
+ if response.status_code == 200:
12
+ data = response.json()
13
+ print(json.dumps(data, indent=2))
14
+ else:
15
+ print(f"Error: {response.text}")
16
+ except Exception as e:
17
+ print(f"Request failed: {e}")
src/api/routes/chat.py CHANGED
@@ -32,15 +32,30 @@ intent_detector = IntentDetector()
32
 
33
  # Initialize Drummond agent
34
  drummond_init_error = None
 
 
 
35
  try:
 
 
 
 
 
 
36
  drummond_agent = CommunicationAgent()
37
  logger.info("Drummond agent created successfully")
 
 
 
 
38
  except Exception as e:
39
  drummond_init_error = str(e)
40
  logger.error(f"Failed to create Drummond agent: {e}")
41
  import traceback
42
  logger.error(f"Traceback: {traceback.format_exc()}")
43
  drummond_agent = None
 
 
44
 
45
  class ChatRequest(BaseModel):
46
  """Chat message request"""
 
32
 
33
  # Initialize Drummond agent
34
  drummond_init_error = None
35
+ drummond_agent = None
36
+ logger.info("Starting Drummond initialization...")
37
+
38
  try:
39
+ # Check if Maritaca key is available
40
+ import os
41
+ has_maritaca = bool(os.environ.get("MARITACA_API_KEY"))
42
+ logger.info(f"MARITACA_API_KEY available: {has_maritaca}")
43
+
44
+ # Create agent
45
  drummond_agent = CommunicationAgent()
46
  logger.info("Drummond agent created successfully")
47
+
48
+ # Note: We can't run async initialize here, it will be done on first use
49
+ logger.info("Drummond agent ready for initialization on first use")
50
+
51
  except Exception as e:
52
  drummond_init_error = str(e)
53
  logger.error(f"Failed to create Drummond agent: {e}")
54
  import traceback
55
  logger.error(f"Traceback: {traceback.format_exc()}")
56
  drummond_agent = None
57
+ finally:
58
+ logger.info(f"Drummond agent final status: {'Available' if drummond_agent else f'Not available - {drummond_init_error}'}")
59
 
60
  class ChatRequest(BaseModel):
61
  """Chat message request"""