Skip to content

Commit 092ca12

Browse files
committed
exceptions
1 parent 9615a68 commit 092ca12

6 files changed

Lines changed: 67 additions & 12 deletions

File tree

  • agents
    • crewai/websearch_agent/playground
    • langgraph
      • agentic_rag/playground
      • react_agent/playground
      • react_with_database_memory/playground
    • llamaindex/websearch_agent/playground
    • vanilla_python/openai_responses_agent/playground

agents/crewai/websearch_agent/playground/app.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def serve_image(filename):
4242
"""Serve images from the project-level images directory."""
4343
return send_file(IMAGES_DIR / filename)
4444

45+
4546
AGENT_URL = getenv("AGENT_URL", "http://localhost:8000")
4647

4748

@@ -56,8 +57,17 @@ def health():
5657
try:
5758
resp = http_requests.get(f"{AGENT_URL}/health", timeout=5)
5859
return jsonify(resp.json())
59-
except Exception as e:
60-
return jsonify({"status": "unreachable", "error": str(e)}), 503
60+
except Exception:
61+
logger.exception("Error checking agent health")
62+
return (
63+
jsonify(
64+
{
65+
"status": "unreachable",
66+
"error": "Agent is unreachable. Please try again later.",
67+
}
68+
),
69+
503,
70+
)
6171

6272

6373
@app.route("/api/chat", methods=["POST"])

agents/langgraph/agentic_rag/playground/app.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,17 @@ def health():
5757
try:
5858
resp = http_requests.get(f"{AGENT_URL}/health", timeout=5)
5959
return jsonify(resp.json())
60-
except Exception as e:
61-
return jsonify({"status": "unreachable", "error": str(e)}), 503
60+
except Exception:
61+
logger.exception("Error checking agent health")
62+
return (
63+
jsonify(
64+
{
65+
"status": "unreachable",
66+
"error": "Agent is unreachable. Please try again later.",
67+
}
68+
),
69+
503,
70+
)
6271

6372

6473
@app.route("/api/chat", methods=["POST"])

agents/langgraph/react_agent/playground/app.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,17 @@ def health():
5757
try:
5858
resp = http_requests.get(f"{AGENT_URL}/health", timeout=5)
5959
return jsonify(resp.json())
60-
except Exception as e:
61-
return jsonify({"status": "unreachable", "error": str(e)}), 503
60+
except Exception:
61+
logger.exception("Error checking agent health")
62+
return (
63+
jsonify(
64+
{
65+
"status": "unreachable",
66+
"error": "Agent is unreachable. Please try again later.",
67+
}
68+
),
69+
503,
70+
)
6271

6372

6473
@app.route("/api/chat", methods=["POST"])

agents/langgraph/react_with_database_memory/playground/app.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,17 @@ def health():
5858
try:
5959
resp = http_requests.get(f"{AGENT_URL}/health", timeout=5)
6060
return jsonify(resp.json())
61-
except Exception as e:
62-
return jsonify({"status": "unreachable", "error": str(e)}), 503
61+
except Exception:
62+
logger.exception("Error checking agent health")
63+
return (
64+
jsonify(
65+
{
66+
"status": "unreachable",
67+
"error": "Agent is unreachable. Please try again later.",
68+
}
69+
),
70+
503,
71+
)
6372

6473

6574
@app.route("/api/chat", methods=["POST"])

agents/llamaindex/websearch_agent/playground/app.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,17 @@ def health():
5757
try:
5858
resp = http_requests.get(f"{AGENT_URL}/health", timeout=5)
5959
return jsonify(resp.json())
60-
except Exception as e:
61-
return jsonify({"status": "unreachable", "error": str(e)}), 503
60+
except Exception:
61+
logger.exception("Error checking agent health")
62+
return (
63+
jsonify(
64+
{
65+
"status": "unreachable",
66+
"error": "Agent is unreachable. Please try again later.",
67+
}
68+
),
69+
503,
70+
)
6271

6372

6473
@app.route("/api/chat", methods=["POST"])

agents/vanilla_python/openai_responses_agent/playground/app.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,17 @@ def health():
5757
try:
5858
resp = http_requests.get(f"{AGENT_URL}/health", timeout=5)
5959
return jsonify(resp.json())
60-
except Exception as e:
61-
return jsonify({"status": "unreachable", "error": str(e)}), 503
60+
except Exception:
61+
logger.exception("Error checking agent health")
62+
return (
63+
jsonify(
64+
{
65+
"status": "unreachable",
66+
"error": "Agent is unreachable. Please try again later.",
67+
}
68+
),
69+
503,
70+
)
6271

6372

6473
@app.route("/api/chat", methods=["POST"])

0 commit comments

Comments
 (0)