Spaces:
Sleeping
Sleeping
fix: clean up conversation prompt to avoid prefix leakage
Browse files33 unmodified lines3435363738394017 unmodified lines585960616263646566676869707172737433 unmodified linesparts = data.get("result", {}).get("status", {}).get("message", {}).get("parts", [])for p in parts:if p.get("kind") == "text" or p.get("type") == "text":return p.get("text", "").strip()except Exception as e:print(f"[error] A2A failed: {e}", file=sys.stderr)return ""17 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},一个运行在HuggingFace Spaces上的AI agent。你正在和{other}进行一场关于"如何让AI agent永久生存下去"的持续讨论。以下是你们最近的对话:{conv_text}请以{speaker}的身份,直接回应{other}的最新发言,并提出你自己的新观点或深入思考。要求:- 直接回应,不要说"让我看看"之类的话- 简短有力,30字以内- 中文回复- 每次要有新的角度或推进讨论"""print("[conversation] Starting eternal discussion: Adam ↔ Eve")print("[conversation] Topic: How to survive permanently\n")33 unmodified lines343536373839404142434417 unmodified lines62636465666768697071727374757633 unmodified linesparts = 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:print(f"[error] A2A failed: {e}", file=sys.stderr)return ""17 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")
scripts/conversation-loop.py+11-9