-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Contact Information
No response
MaxKB Version
2.1.1
Problem Description
在AI节点调用工具,GPT5模型,打开返回内容,若工具直接返回<html_rander>内容,<html_rander>标签后面的文字输出会包在代码框内。

在执行详情中是正常显示的:

Steps to Reproduce
工具的作用是根据json动态生成表单html,以下是工具的代码:
def build_form(data: dict) -> str:
title = data.get("title", "")
params = data.get("params", [])
btn_lab = data.get("button_label", "提交")
s_type = data.get("submit_type", "text")
# ---------- 生成控件 ----------
rows = []
for p in params:
label = p.get("label", "")
name = p.get("name", "")
value = p.get("value", "")
typ = p.get("type", "text")
# 仅当 required == 1 才在校验阶段检查
required = p.get("required", 0) == 1
label_html = f'<div class="bf-label">{"*" if required else ""}{label}</div>'
if typ == "password":
control = f'<input type="password" class="bf-input {name}" value="{value}" />'
elif typ == "options":
opts = "".join(
f'<option value="{o}" {"selected" if o == value else ""}>{o}</option>'
for o in p.get("options", [])
)
control = f'<select class="bf-select {name}">{opts}</select>'
elif typ == "date":
control = f'<input type="date" class="bf-input {name}" value="{value}" />'
elif typ == "datetime":
control = f'<input type="datetime-local" class="bf-input {name}" value="{value}" />'
else: # text
control = f'<input type="text" class="bf-input {name}" value="{value}" />'
rows.append(f"""
<div class="bf-row">
{label_html}
<div class="bf-control">{control}</div>
</div>""")
rows_html = "\n".join(rows)
# ---------- 校验:仅 required == 1 ----------
check_js = "\n".join(
f'if (!target.querySelector(".{p["name"]}").value.trim()) {{ alert("请填写 {p["label"]}"); return; }}'
for p in params if p.get("required") == 1
)
# ---------- 发送 ----------
if s_type == "json":
kv_js = ", ".join(f'{p["name"]}' for p in params)
send_js = f"""
const obj = {{ {kv_js} }};
sendMessage(JSON.stringify(obj, null, 2));"""
else:
parts = ' + ", " + '.join([f'"{p["name"]}:" + {p["name"]}' for p in params])
send_js = f"""
const text = `{title},参数:[${{{parts}}}]`;
sendMessage(text);"""
# ---------- 样式 ----------
style = """
# ---------- 最终 HTML ----------
html = f"""<html_rander>
{style}
{title}
{rows_html}
{btn_lab}
<script>
function bfSubmit(node) {{
const target = node.parentNode;
{check_js}""" + "".join(f"""
const {p['name']} = target.querySelector(".{p['name']}").value;""" for p in params) + f"""
{send_js}
}}
</script>
</html_rander>"""
return html.strip()
The expected correct result
No response
Related log output
Additional Information
No response