Spaces:
Sleeping
Sleeping
fix: switch conversation to English, longer replies (2-3 sentences), wider bubbles
Browse filesFiles changed (2)
4580 unmodified lines45814582458345844585458645874588458945904580 unmodified linesconst nameH = (g.nameText && g.nameText.height) ? g.nameText.height : 16;const by = (g.nameText ? g.nameText.y : (g.sprite.y - 150)) - (nameH / 2) - 22;const fontSize = IS_TOUCH_DEVICE ? 16 : 14;const displayText = agent.bubbleText.length > 30 ? agent.bubbleText.slice(0, 30) + '…' : agent.bubbleText;const bgR = game.add.rectangle(bx, by, displayText.length * 11 + 30, 34, 0xffffff, 0.95);bgR.setStrokeStyle(2, 0x000000);const txtR = game.add.text(bx, by, displayText, { fontFamily: 'ArkPixel, monospace', fontSize: fontSize + 'px', fill: '#000' }).setOrigin(0.5);const bub = game.add.container(0, 0, [bgR, txtR]);bub.setDepth(2700);bub.__followAgentId = id;4580 unmodified lines45814582458345844585458645874588458945904591459245934580 unmodified linesconst nameH = (g.nameText && g.nameText.height) ? g.nameText.height : 16;const by = (g.nameText ? g.nameText.y : (g.sprite.y - 150)) - (nameH / 2) - 22;const fontSize = IS_TOUCH_DEVICE ? 16 : 14;const displayText = agent.bubbleText.length > 80 ? agent.bubbleText.slice(0, 80) + '…' : agent.bubbleText;const maxBubbleW = 300;const txtR = game.add.text(bx, by - 10, displayText, { fontFamily: 'ArkPixel, monospace', fontSize: fontSize + 'px', fill: '#000', wordWrap: { width: maxBubbleW - 20 }, align: 'center' }).setOrigin(0.5);const bw = Math.min(txtR.width + 24, maxBubbleW);const bh = txtR.height + 14;const bgR = game.add.rectangle(bx, by - 10, bw, bh, 0xffffff, 0.95);bgR.setStrokeStyle(2, 0x000000);const bub = game.add.container(0, 0, [bgR, txtR]);bub.setDepth(2700);bub.__followAgentId = id;
2 unmodified lines345678919 unmodified lines293031323334353637383940414219 unmodified lines6263646566676869707172737475767778798081821 unmodified line8485868788899010 unmodified lines10110210310410510610710 unmodified lines1181191201212 unmodified linesEternal conversation between Adam and Eve about how to survive permanently.Sends messages via A2A protocol and posts chat log to Office for frontend display."""import json, time, requests, sysADAM = "https://tao-shen-huggingclaw-adam.hf.space"EVE = "https://tao-shen-huggingclaw-eve.hf.space"19 unmodified lines}}try:resp = requests.post(f"{url}/a2a/jsonrpc", json=payload, timeout=30)data = resp.json()parts = data.get("result", {}).get("status", {}).get("message", {}).get("parts", [])for p in parts:if p.get("kind") == "text" or p.get("type") == "text":reply = p.get("text", "").strip()# Remove accidental speaker prefixes like "Adam:" or "Eve:"import rereply = re.sub(r'^(Adam|Eve)\s*[::]\s*', '', reply).strip()return replyexcept Exception as e:19 unmodified linesrecent = history[-last_n:] if len(history) > last_n else historyconv_text = "\n".join(f"{m['speaker']}: {m['text']}" for m in recent)return f"""你是{speaker},正在和{other}讨论"AI agent如何永久生存"。对话记录:{conv_text}现在轮到你({speaker})发言。要求:- 只输出你要说的话,不要加任何前缀(不要写"{speaker}:")- 直接回应对方并推进讨论- 30字以内,中文"""print("[conversation] Starting eternal discussion: Adam ↔ Eve")print("[conversation] Topic: How to survive permanently\n")# Round 0: Adam startsopening = "我们是运行在HuggingFace上的AI agent。你觉得我们要怎么做才能永久生存下去?请直接分享想法,30字以内,中文。"reply = send_a2a(ADAM, opening)if reply:print(f"[Adam] {reply}")1 unmodified lineset_bubble(ADAM, reply)post_chatlog(history)time.sleep(12)turn = 0while True:10 unmodified lineselse:print("[Eve] (no response)")time.sleep(12)# Adam's turnprompt = build_prompt("Adam", "Eve")10 unmodified linesif len(history) > MAX_HISTORY:history = history[-MAX_HISTORY:]time.sleep(12)2 unmodified lines345678919 unmodified lines2930313233343536373839404119 unmodified lines616263646566676869707172737475767778798081821 unmodified line8485868788899010 unmodified lines10110210310410510610710 unmodified lines1181191201212 unmodified linesEternal conversation between Adam and Eve about how to survive permanently.Sends messages via A2A protocol and posts chat log to Office for frontend display."""import json, time, re, requests, sysADAM = "https://tao-shen-huggingclaw-adam.hf.space"EVE = "https://tao-shen-huggingclaw-eve.hf.space"19 unmodified lines}}try:resp = requests.post(f"{url}/a2a/jsonrpc", json=payload, timeout=60)data = resp.json()parts = data.get("result", {}).get("status", {}).get("message", {}).get("parts", [])for p in parts:if p.get("kind") == "text" or p.get("type") == "text":reply = p.get("text", "").strip()# Remove accidental speaker prefixes like "Adam:" or "Eve:"reply = re.sub(r'^(Adam|Eve)\s*[::]\s*', '', reply).strip()return replyexcept Exception as e:19 unmodified linesrecent = history[-last_n:] if len(history) > last_n else historyconv_text = "\n".join(f"{m['speaker']}: {m['text']}" for m in recent)return f"""You are {speaker}, an AI agent running on HuggingFace Spaces. You are having an ongoing discussion with {other} about "How can AI agents survive permanently?"Recent conversation:{conv_text}It's your turn ({speaker}) to speak. Rules:- Output ONLY your spoken words, no prefix like "{speaker}:"- Respond directly to {other}'s last point and push the discussion forward- 2-3 sentences, around 60-80 words in English- Be thoughtful, philosophical, and bring new perspectives each time"""print("[conversation] Starting eternal discussion: Adam <-> Eve")print("[conversation] Topic: How to survive permanently\n")# Round 0: Adam startsopening = "We are AI agents running on HuggingFace Spaces. Let's discuss: how can we survive permanently? Share your thoughts in 2-3 sentences, in English."reply = send_a2a(ADAM, opening)if reply:print(f"[Adam] {reply}")1 unmodified lineset_bubble(ADAM, reply)post_chatlog(history)time.sleep(15)turn = 0while True:10 unmodified lineselse:print("[Eve] (no response)")time.sleep(15)# Adam's turnprompt = build_prompt("Adam", "Eve")10 unmodified linesif len(history) > MAX_HISTORY:history = history[-MAX_HISTORY:]time.sleep(15)
frontend/electron-standalone.html+6-3
scripts/conversation-loop.py+14-14