"""塞一条带**裸 URL** 的助手回复(旧版 extractUrls 认不出来的那种)。 ★ 用户报"操作栏里应该有『打开网页』按钮,但没显示"。 旧实现只认 `](` 紧挨着的 markdown 链接,裸 URL 一律漏 → extractUrls 返回空 → 按钮整个不显示。 这条回复就是用来验证修好没有的。 """ import json import sys import urllib.request try: sys.stdout.reconfigure(encoding="utf-8", errors="replace") except Exception: pass URL = "http://127.0.0.1:15199" def call(path, payload=None, method="POST", timeout=60): data = json.dumps(payload, ensure_ascii=False).encode("utf-8") if payload is not None else None req = urllib.request.Request( URL + path, data=data, method=method, headers={"Content-Type": "application/json; charset=utf-8"}, ) with urllib.request.urlopen(req, timeout=timeout) as r: return json.loads(r.read().decode("utf-8")) content = ( "给你几个链接,写法故意各不相同(旧版只有第一种能被认出来):\n\n" "1. 标准的:[Example 官网](https://example.com)\n" "2. 中间有空格的:[Example 中文] (https://example.com/index-zh)\n" "3. **裸 URL**:直接去 https://www.iana.org/help/example-domains 看\n" "4. 尖括号包裹:\n" "5. 中文标点紧跟:也可以看 https://www.rfc-editor.org/rfc/rfc2606,里面有说明\n" ) convs = call("/api/conversations", None, "GET").get("conversations") or [] cid = convs[0]["id"] if convs else "c_main" print("往", cid, "写消息…") res = call(f"/api/conversations/{cid}", {"messages": [ {"role": "user", "content": "给我几个链接"}, {"role": "assistant", "content": content}, ]}, "PATCH") full = res.get("conversation") or {} print("现在", len(full.get("messages") or []), "条消息")