Spaces:
Sleeping
Sleeping
Increase max wait time and messages to prep users for long waits when its a cold start
Browse files- ui/contentagentui.py +18 -16
ui/contentagentui.py
CHANGED
|
@@ -93,32 +93,34 @@ class ContentAgentUI:
|
|
| 93 |
self.prompt.submit(self._call_agent, inputs=[self.prompt, self.agent_state], outputs=self.reply)
|
| 94 |
|
| 95 |
# Event: Start Agent (wake → health-check → init → reveal main panel)
|
|
|
|
| 96 |
def on_start():
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
if not ok:
|
| 102 |
-
|
| 103 |
-
yield (f"Wake failed: {err or 'unknown error'}", gr.update(), gr.update(), None)
|
| 104 |
return
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
yield ("Endpoint awake ✅. Checking health…", gr.update(), gr.update(), None)
|
| 108 |
healthy, msg = is_endpoint_healthy(self.endpoint_uri)
|
| 109 |
if not healthy:
|
| 110 |
-
yield (f"
|
| 111 |
return
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
yield ("Initializing agent…", gr.update(), gr.update(), None)
|
| 115 |
try:
|
| 116 |
agent = self.agent_initializer(self.endpoint_uri)
|
| 117 |
except Exception as e:
|
| 118 |
-
yield (f"Agent init failed: {e}"
|
| 119 |
return
|
| 120 |
-
|
| 121 |
-
# 4) success → hide control panel, show main
|
| 122 |
yield ("Agent initialized ✅", gr.update(visible=False), gr.update(visible=True), agent)
|
| 123 |
|
| 124 |
# wire the button: outputs are (status_text, control_panel_update, main_panel_update, agent_state)
|
|
|
|
| 93 |
self.prompt.submit(self._call_agent, inputs=[self.prompt, self.agent_state], outputs=self.reply)
|
| 94 |
|
| 95 |
# Event: Start Agent (wake → health-check → init → reveal main panel)
|
| 96 |
+
|
| 97 |
def on_start():
|
| 98 |
+
lines = []
|
| 99 |
+
def push(s):
|
| 100 |
+
lines.append(s)
|
| 101 |
+
return ("\n".join(lines), gr.update(), gr.update(), None)
|
| 102 |
+
|
| 103 |
+
yield push("Waking endpoint… (this can take several minutes for cold starts)")
|
| 104 |
+
ok, err = wake_endpoint(self.endpoint_uri, max_wait=600, poll_every=5.0, log=lambda m: lines.append(m))
|
| 105 |
+
yield push(lines[-1] if lines else "…") # flush last log line
|
| 106 |
+
|
| 107 |
if not ok:
|
| 108 |
+
yield push(f"[Server message] {err or 'wake failed'}")
|
|
|
|
| 109 |
return
|
| 110 |
+
|
| 111 |
+
yield push("Endpoint awake ✅. Checking health…")
|
|
|
|
| 112 |
healthy, msg = is_endpoint_healthy(self.endpoint_uri)
|
| 113 |
if not healthy:
|
| 114 |
+
yield push(f"[Server message] {msg}")
|
| 115 |
return
|
| 116 |
+
|
| 117 |
+
yield push("Initializing agent…")
|
|
|
|
| 118 |
try:
|
| 119 |
agent = self.agent_initializer(self.endpoint_uri)
|
| 120 |
except Exception as e:
|
| 121 |
+
yield push(f"Agent init failed: {e}")
|
| 122 |
return
|
| 123 |
+
|
|
|
|
| 124 |
yield ("Agent initialized ✅", gr.update(visible=False), gr.update(visible=True), agent)
|
| 125 |
|
| 126 |
# wire the button: outputs are (status_text, control_panel_update, main_panel_update, agent_state)
|