Spaces:
Paused
Paused
fix: revert localhost — conversation-loop runs on God Space, not Home
Browse filesconversation-loop.py runs on the God Space (RUN_ORCHESTRATOR=1), so
localhost:7860 hits God's own OpenClaw, not Home's. Reverted to using
HOME external URL. Added detailed logging to post_chatlog and
set_bubble to diagnose why chatroom updates fail.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- scripts/conversation-loop.py +15 -9
scripts/conversation-loop.py
CHANGED
|
@@ -47,7 +47,6 @@ sys.stderr.reconfigure(line_buffering=True)
|
|
| 47 |
|
| 48 |
# ── Endpoints ──────────────────────────────────────────────────────────────────
|
| 49 |
HOME = "https://tao-shen-huggingclaw-home.hf.space"
|
| 50 |
-
HOME_LOCAL = "http://localhost:7860" # Internal calls — avoid round-tripping through HF proxy
|
| 51 |
ADAM_SPACE = "https://tao-shen-huggingclaw-adam.hf.space"
|
| 52 |
ADAM_SPACE_ID = "tao-shen/HuggingClaw-Adam"
|
| 53 |
EVE_SPACE = "https://tao-shen-huggingclaw-eve.hf.space"
|
|
@@ -1088,7 +1087,7 @@ def action_claude_code_god(task):
|
|
| 1088 |
ts_end = datetime.datetime.utcnow().strftime("%H:%M")
|
| 1089 |
entry = {"speaker": "God", "time": ts_end, "text": msg_en, "text_zh": msg_en}
|
| 1090 |
history.append(entry)
|
| 1091 |
-
set_bubble(
|
| 1092 |
post_chatlog(history)
|
| 1093 |
persist_turn("God", turn_count, msg_en, msg_en, [], workflow_state, child_state["stage"])
|
| 1094 |
|
|
@@ -1614,10 +1613,15 @@ def parse_bilingual(text):
|
|
| 1614 |
|
| 1615 |
|
| 1616 |
def post_chatlog(entries):
|
|
|
|
| 1617 |
try:
|
| 1618 |
-
requests.post(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1619 |
except Exception as e:
|
| 1620 |
-
print(f"[CHATLOG]
|
| 1621 |
|
| 1622 |
|
| 1623 |
# ── Persistent conversation log → HF Dataset ──────────────────────────────
|
|
@@ -1691,10 +1695,12 @@ def flush_chatlog(max_retries=2):
|
|
| 1691 |
|
| 1692 |
def set_bubble(url, text_en, text_zh=""):
|
| 1693 |
try:
|
| 1694 |
-
requests.post(f"{url}/api/bubble",
|
| 1695 |
-
json={"text": text_en, "text_zh": text_zh or text_en}, timeout=
|
| 1696 |
-
|
| 1697 |
-
|
|
|
|
|
|
|
| 1698 |
|
| 1699 |
|
| 1700 |
# ══════════════════════════════════════════════════════════════════════════════
|
|
@@ -2523,7 +2529,7 @@ def do_god_turn_a2a():
|
|
| 2523 |
ts = datetime.datetime.utcnow().strftime("%H:%M")
|
| 2524 |
entry = {"speaker": "God", "time": ts, "text": en[:500], "text_zh": zh[:500]}
|
| 2525 |
history.append(entry)
|
| 2526 |
-
set_bubble(
|
| 2527 |
post_chatlog(history)
|
| 2528 |
persist_turn("God", turn_count, en, zh, [], workflow_state, child_state["stage"])
|
| 2529 |
|
|
|
|
| 47 |
|
| 48 |
# ── Endpoints ──────────────────────────────────────────────────────────────────
|
| 49 |
HOME = "https://tao-shen-huggingclaw-home.hf.space"
|
|
|
|
| 50 |
ADAM_SPACE = "https://tao-shen-huggingclaw-adam.hf.space"
|
| 51 |
ADAM_SPACE_ID = "tao-shen/HuggingClaw-Adam"
|
| 52 |
EVE_SPACE = "https://tao-shen-huggingclaw-eve.hf.space"
|
|
|
|
| 1087 |
ts_end = datetime.datetime.utcnow().strftime("%H:%M")
|
| 1088 |
entry = {"speaker": "God", "time": ts_end, "text": msg_en, "text_zh": msg_en}
|
| 1089 |
history.append(entry)
|
| 1090 |
+
set_bubble(HOME, msg_en[:200], msg_en[:200])
|
| 1091 |
post_chatlog(history)
|
| 1092 |
persist_turn("God", turn_count, msg_en, msg_en, [], workflow_state, child_state["stage"])
|
| 1093 |
|
|
|
|
| 1613 |
|
| 1614 |
|
| 1615 |
def post_chatlog(entries):
|
| 1616 |
+
url = f"{HOME}/api/chatlog"
|
| 1617 |
try:
|
| 1618 |
+
resp = requests.post(url, json={"messages": entries[-40:]}, timeout=10)
|
| 1619 |
+
if resp.status_code != 200:
|
| 1620 |
+
print(f"[CHATLOG] POST {url} → {resp.status_code}: {resp.text[:200]}", flush=True)
|
| 1621 |
+
else:
|
| 1622 |
+
print(f"[CHATLOG] Posted {len(entries)} entries OK", flush=True)
|
| 1623 |
except Exception as e:
|
| 1624 |
+
print(f"[CHATLOG] POST {url} failed: {e}", flush=True)
|
| 1625 |
|
| 1626 |
|
| 1627 |
# ── Persistent conversation log → HF Dataset ──────────────────────────────
|
|
|
|
| 1695 |
|
| 1696 |
def set_bubble(url, text_en, text_zh=""):
|
| 1697 |
try:
|
| 1698 |
+
resp = requests.post(f"{url}/api/bubble",
|
| 1699 |
+
json={"text": text_en, "text_zh": text_zh or text_en}, timeout=10)
|
| 1700 |
+
if resp.status_code != 200:
|
| 1701 |
+
print(f"[BUBBLE] POST {url}/api/bubble → {resp.status_code}", flush=True)
|
| 1702 |
+
except Exception as e:
|
| 1703 |
+
print(f"[BUBBLE] POST {url}/api/bubble failed: {e}", flush=True)
|
| 1704 |
|
| 1705 |
|
| 1706 |
# ══════════════════════════════════════════════════════════════════════════════
|
|
|
|
| 2529 |
ts = datetime.datetime.utcnow().strftime("%H:%M")
|
| 2530 |
entry = {"speaker": "God", "time": ts, "text": en[:500], "text_zh": zh[:500]}
|
| 2531 |
history.append(entry)
|
| 2532 |
+
set_bubble(HOME, en[:200], zh[:200])
|
| 2533 |
post_chatlog(history)
|
| 2534 |
persist_turn("God", turn_count, en, zh, [], workflow_state, child_state["stage"])
|
| 2535 |
|