Claude Code commited on
Commit
dcc9bec
·
1 Parent(s): 90077e9

Claude Code: The error at line 758 suggests

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -753,34 +753,36 @@ def create_agent_office_with_ws():
753
  """
754
  app = create_agent_office()
755
 
756
- # Add a custom route for polling agent thoughts
757
- # This is a simple polling endpoint; for true WebSocket, use websockets library
758
- @app.get("/api/thoughts")
759
  def api_get_thoughts(limit: int = 50):
760
  """Get recent agent thoughts as JSON."""
761
  return ws_manager.get_recent_thoughts(limit)
762
 
763
- @app.get("/api/thoughts/stats")
764
  def api_get_stats():
765
  """Get WebSocket manager statistics."""
766
  return ws_manager.get_stats()
767
 
768
- @app.post("/api/thoughts/clear")
769
  def api_clear_thoughts():
770
  """Clear the thought history."""
771
  ws_manager.clear_history()
772
  return {"status": "cleared"}
773
 
774
- @app.get("/api/agent/status")
775
  def api_agent_status():
776
  """Get current agent status as JSON."""
777
  return load_cain_status()
778
 
779
- @app.get("/api/agent/registry")
780
  def api_agent_registry():
781
  """Get agent registry as JSON."""
782
  return load_agent_registry()
783
 
 
 
 
 
 
 
 
784
  return app
785
 
786
 
 
753
  """
754
  app = create_agent_office()
755
 
756
+ # Add custom routes for polling agent thoughts
757
+ # Use Gradio's add_api_route() method for custom FastAPI routes
 
758
  def api_get_thoughts(limit: int = 50):
759
  """Get recent agent thoughts as JSON."""
760
  return ws_manager.get_recent_thoughts(limit)
761
 
 
762
  def api_get_stats():
763
  """Get WebSocket manager statistics."""
764
  return ws_manager.get_stats()
765
 
 
766
  def api_clear_thoughts():
767
  """Clear the thought history."""
768
  ws_manager.clear_history()
769
  return {"status": "cleared"}
770
 
 
771
  def api_agent_status():
772
  """Get current agent status as JSON."""
773
  return load_cain_status()
774
 
 
775
  def api_agent_registry():
776
  """Get agent registry as JSON."""
777
  return load_agent_registry()
778
 
779
+ # Add routes using Gradio's add_api_route method
780
+ app.add_api_route("/api/thoughts", api_get_thoughts, methods=["GET"])
781
+ app.add_api_route("/api/thoughts/stats", api_get_stats, methods=["GET"])
782
+ app.add_api_route("/api/thoughts/clear", api_clear_thoughts, methods=["POST"])
783
+ app.add_api_route("/api/agent/status", api_agent_status, methods=["GET"])
784
+ app.add_api_route("/api/agent/registry", api_agent_registry, methods=["GET"])
785
+
786
  return app
787
 
788