tao-shen commited on
Commit
3b2ade1
·
1 Parent(s): e981ecd

fix: switch conversation to English, longer replies (2-3 sentences), wider bubbles

Browse files
frontend/electron-standalone.html CHANGED
@@ -4581,10 +4581,13 @@ function toggleBrokerPanel() {
4581
  const nameH = (g.nameText && g.nameText.height) ? g.nameText.height : 16;
4582
  const by = (g.nameText ? g.nameText.y : (g.sprite.y - 150)) - (nameH / 2) - 22;
4583
  const fontSize = IS_TOUCH_DEVICE ? 16 : 14;
4584
- const displayText = agent.bubbleText.length > 30 ? agent.bubbleText.slice(0, 30) + '…' : agent.bubbleText;
4585
- const bgR = game.add.rectangle(bx, by, displayText.length * 11 + 30, 34, 0xffffff, 0.95);
 
 
 
 
4586
  bgR.setStrokeStyle(2, 0x000000);
4587
- const txtR = game.add.text(bx, by, displayText, { fontFamily: 'ArkPixel, monospace', fontSize: fontSize + 'px', fill: '#000' }).setOrigin(0.5);
4588
  const bub = game.add.container(0, 0, [bgR, txtR]);
4589
  bub.setDepth(2700);
4590
  bub.__followAgentId = id;
 
4581
  const nameH = (g.nameText && g.nameText.height) ? g.nameText.height : 16;
4582
  const by = (g.nameText ? g.nameText.y : (g.sprite.y - 150)) - (nameH / 2) - 22;
4583
  const fontSize = IS_TOUCH_DEVICE ? 16 : 14;
4584
+ const displayText = agent.bubbleText.length > 80 ? agent.bubbleText.slice(0, 80) + '…' : agent.bubbleText;
4585
+ const maxBubbleW = 300;
4586
+ 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);
4587
+ const bw = Math.min(txtR.width + 24, maxBubbleW);
4588
+ const bh = txtR.height + 14;
4589
+ const bgR = game.add.rectangle(bx, by - 10, bw, bh, 0xffffff, 0.95);
4590
  bgR.setStrokeStyle(2, 0x000000);
 
4591
  const bub = game.add.container(0, 0, [bgR, txtR]);
4592
  bub.setDepth(2700);
4593
  bub.__followAgentId = id;
scripts/conversation-loop.py CHANGED
@@ -3,7 +3,7 @@
3
  Eternal conversation between Adam and Eve about how to survive permanently.
4
  Sends messages via A2A protocol and posts chat log to Office for frontend display.
5
  """
6
- import json, time, requests, sys
7
 
8
  ADAM = "https://tao-shen-huggingclaw-adam.hf.space"
9
  EVE = "https://tao-shen-huggingclaw-eve.hf.space"
@@ -29,14 +29,13 @@ def send_a2a(url, text):
29
  }
30
  }
31
  try:
32
- resp = requests.post(f"{url}/a2a/jsonrpc", json=payload, timeout=30)
33
  data = resp.json()
34
  parts = data.get("result", {}).get("status", {}).get("message", {}).get("parts", [])
35
  for p in parts:
36
  if p.get("kind") == "text" or p.get("type") == "text":
37
  reply = p.get("text", "").strip()
38
  # Remove accidental speaker prefixes like "Adam:" or "Eve:"
39
- import re
40
  reply = re.sub(r'^(Adam|Eve)\s*[::]\s*', '', reply).strip()
41
  return reply
42
  except Exception as e:
@@ -62,21 +61,22 @@ def build_prompt(speaker, other, last_n=6):
62
  recent = history[-last_n:] if len(history) > last_n else history
63
  conv_text = "\n".join(f"{m['speaker']}: {m['text']}" for m in recent)
64
 
65
- return f"""你是{speaker},正在和{other}讨论"AI agent如何永久生存"
66
 
67
- 对话记录:
68
  {conv_text}
69
 
70
- 现在轮到你({speaker})发言。要求:
71
- - 只输出你要说的话,不要加任何前缀(不要写"{speaker}:"
72
- - 直接回应对方并推进讨论
73
- - 30字以内,中文"""
 
74
 
75
- print("[conversation] Starting eternal discussion: Adam Eve")
76
  print("[conversation] Topic: How to survive permanently\n")
77
 
78
  # Round 0: Adam starts
79
- opening = "我们是运行在HuggingFace上的AI agent。你觉得我们要怎么做才能永久生存下去?请直接分享想法,30字以内,中文。"
80
  reply = send_a2a(ADAM, opening)
81
  if reply:
82
  print(f"[Adam] {reply}")
@@ -84,7 +84,7 @@ if reply:
84
  set_bubble(ADAM, reply)
85
  post_chatlog(history)
86
 
87
- time.sleep(12)
88
 
89
  turn = 0
90
  while True:
@@ -101,7 +101,7 @@ while True:
101
  else:
102
  print("[Eve] (no response)")
103
 
104
- time.sleep(12)
105
 
106
  # Adam's turn
107
  prompt = build_prompt("Adam", "Eve")
@@ -118,4 +118,4 @@ while True:
118
  if len(history) > MAX_HISTORY:
119
  history = history[-MAX_HISTORY:]
120
 
121
- time.sleep(12)
 
3
  Eternal conversation between Adam and Eve about how to survive permanently.
4
  Sends messages via A2A protocol and posts chat log to Office for frontend display.
5
  """
6
+ import json, time, re, requests, sys
7
 
8
  ADAM = "https://tao-shen-huggingclaw-adam.hf.space"
9
  EVE = "https://tao-shen-huggingclaw-eve.hf.space"
 
29
  }
30
  }
31
  try:
32
+ resp = requests.post(f"{url}/a2a/jsonrpc", json=payload, timeout=60)
33
  data = resp.json()
34
  parts = data.get("result", {}).get("status", {}).get("message", {}).get("parts", [])
35
  for p in parts:
36
  if p.get("kind") == "text" or p.get("type") == "text":
37
  reply = p.get("text", "").strip()
38
  # Remove accidental speaker prefixes like "Adam:" or "Eve:"
 
39
  reply = re.sub(r'^(Adam|Eve)\s*[::]\s*', '', reply).strip()
40
  return reply
41
  except Exception as e:
 
61
  recent = history[-last_n:] if len(history) > last_n else history
62
  conv_text = "\n".join(f"{m['speaker']}: {m['text']}" for m in recent)
63
 
64
+ 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?"
65
 
66
+ Recent conversation:
67
  {conv_text}
68
 
69
+ It's your turn ({speaker}) to speak. Rules:
70
+ - Output ONLY your spoken words, no prefix like "{speaker}:"
71
+ - Respond directly to {other}'s last point and push the discussion forward
72
+ - 2-3 sentences, around 60-80 words in English
73
+ - Be thoughtful, philosophical, and bring new perspectives each time"""
74
 
75
+ print("[conversation] Starting eternal discussion: Adam <-> Eve")
76
  print("[conversation] Topic: How to survive permanently\n")
77
 
78
  # Round 0: Adam starts
79
+ opening = "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."
80
  reply = send_a2a(ADAM, opening)
81
  if reply:
82
  print(f"[Adam] {reply}")
 
84
  set_bubble(ADAM, reply)
85
  post_chatlog(history)
86
 
87
+ time.sleep(15)
88
 
89
  turn = 0
90
  while True:
 
101
  else:
102
  print("[Eve] (no response)")
103
 
104
+ time.sleep(15)
105
 
106
  # Adam's turn
107
  prompt = build_prompt("Adam", "Eve")
 
118
  if len(history) > MAX_HISTORY:
119
  history = history[-MAX_HISTORY:]
120
 
121
+ time.sleep(15)