dknowc-dsh 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/skills/dknowc-official-doc-writer/README.md +15 -38
- package/skills/dknowc-official-doc-writer/SKILL.md +111 -218
- package/skills/dknowc-official-doc-writer/reference/local_memory_guide.md +53 -0
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +132 -0
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +16 -16
- package/skills/dknowc-official-doc-writer/reference/revision_workflow.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/sample_search_result.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/sample_trace_report.html +226 -76
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +35 -32
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +12 -12
- package/skills/dknowc-official-doc-writer/reference/standards/01_report.md +3 -2
- package/skills/dknowc-official-doc-writer/reference/standards/02_qingshi.md +3 -2
- package/skills/dknowc-official-doc-writer/reference/standards/03_pifu.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/04_tongzhi.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/05_yijian.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/06_han.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/08_tongbao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/09_tonggao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/10_gonggao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/11_fuhan_approve.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/12_fuhan_objection.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/13_reminder.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/14_generic.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/16_decision.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/18_order.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/19_gazette.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/20_motion.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/22_application.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/23_publicity.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/task_router.md +10 -10
- package/skills/dknowc-official-doc-writer/scripts/api_key.py +41 -0
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +31 -6
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +30 -26
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +48 -18
- package/skills/dknowc-official-doc-writer/scripts/local_memory.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +7 -11
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +49 -8
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +220 -125
- package/skills/dknowc-official-doc-writer/scripts/review_document.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +34 -44
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +3 -3
- package/skills/dknowc-ppt-assistant/README.md +4 -4
- package/skills/dknowc-ppt-assistant/SKILL.md +16 -20
- package/skills/dknowc-ppt-assistant/references/content-pack.md +3 -3
- package/skills/dknowc-ppt-assistant/references/material_usage.md +9 -6
- package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +120 -0
- package/skills/dknowc-ppt-assistant/references/sample_search_result.md +1 -1
- package/skills/dknowc-ppt-assistant/references/sample_trace_report.html +500 -0
- package/skills/dknowc-ppt-assistant/references/search_intro.md +1 -1
- package/skills/dknowc-ppt-assistant/scripts/api_key.py +41 -0
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +54 -13
- package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +56 -9
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +260 -118
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +65 -15
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +8 -8
- package/skills/dknowc-ppt-assistant/workflows/routing.md +1 -1
- package/skills/dknowc-trusted-consulting/README.md +8 -9
- package/skills/dknowc-trusted-consulting/SKILL.md +47 -32
- package/skills/dknowc-trusted-consulting/reference/consult_intro.md +3 -35
- package/skills/dknowc-trusted-consulting/reference/onboarding_scripts.md +132 -0
- package/skills/dknowc-trusted-consulting/reference/sample_trace_report.html +105 -60
- package/skills/dknowc-trusted-consulting/scripts/api_key.py +41 -0
- package/skills/dknowc-trusted-consulting/scripts/gov_chat.py +39 -19
- package/skills/dknowc-trusted-consulting/scripts/initialize.py +64 -20
- package/skills/dknowc-trusted-consulting/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-trusted-consulting/scripts/register_key.mjs +120 -21
- package/skills/dknowc-trusted-consulting/scripts/render_trace_html.py +165 -161
- package/skills/dknowc-trusted-search/README.md +1 -1
- package/skills/dknowc-trusted-search/SKILL.md +32 -33
- package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +132 -0
- package/skills/dknowc-trusted-search/reference/sample_trace_report.html +108 -52
- package/skills/dknowc-trusted-search/scripts/api_key.py +41 -0
- package/skills/dknowc-trusted-search/scripts/deep_query.py +81 -9
- package/skills/dknowc-trusted-search/scripts/initialize.py +65 -17
- package/skills/dknowc-trusted-search/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +111 -24
- package/skills/dknowc-trusted-search/scripts/render_policy_visualization.py +2 -3
- package/skills/dknowc-trusted-search/scripts/render_trace_html.py +298 -226
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +80 -11
- package/src/index.js +3 -3
- package/skills/dknowc-official-doc-writer/official-docs/input/mcp_intro_content.md +0 -61
- package/skills/dknowc-trusted-search/reference/search_intro.md +0 -79
|
@@ -179,8 +179,9 @@ def content_segments(item: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
|
179
179
|
def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict[str, str]] = None) -> Dict[str, str]:
|
|
180
180
|
vo = item.get("vo") if isinstance(item.get("vo"), dict) else {}
|
|
181
181
|
segment = segment or {}
|
|
182
|
+
# segment 的 id 是文章内段落序号(每篇各自从 1 起),不是材料角标号,不得用作材料 id,
|
|
183
|
+
# 否则多篇材料的段落 id 同为 "1" 会互相冲突,导致角标绑定错乱。
|
|
182
184
|
explicit_id = first_str(
|
|
183
|
-
segment.get("id"),
|
|
184
185
|
item.get("角标"),
|
|
185
186
|
item.get("编号"),
|
|
186
187
|
item.get("index"),
|
|
@@ -223,11 +224,33 @@ def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict
|
|
|
223
224
|
"url": first_str(item.get("sourceUrl"), item.get("source_url"), item.get("源网址"), item.get("原文链接"), item.get("url"), item.get("原文"), vo.get("sourceUrl"), vo.get("url")),
|
|
224
225
|
"policy_url": first_str(item.get("policyUrl"), item.get("policy_url"), item.get("知识专库原文"), vo.get("policyUrl")),
|
|
225
226
|
"excerpt": segment.get("text") or paragraph_text(item),
|
|
226
|
-
"section": first_str(
|
|
227
|
+
"section": first_str(item.get("正文对应"), item.get("section"), item.get("支撑")),
|
|
227
228
|
"kind": first_str(item.get("类型"), item.get("type"), item.get("素材类型"), vo.get("typeName"), "材料"),
|
|
228
229
|
"verify_note": first_str(item.get("核验"), item.get("verification"), item.get("核验说明")),
|
|
229
230
|
"area": first_str(item.get("intentionArea"), item.get("area"), item.get("地域")),
|
|
230
231
|
}
|
|
232
|
+
# 原文位置标题链:接口返回的段落标题即该段在原文件中的章节位置(自带层级,以 > 分隔),
|
|
233
|
+
# 统一转为 › 展示;悬停 title 提供含文章标题的完整链。段落标题与文章标题相同时只留一级。
|
|
234
|
+
# 一篇材料多段时取首个非空段落标题作位置(材料一篇一卡,不按段落拆卡,防止角标错位)。
|
|
235
|
+
seg_title = ""
|
|
236
|
+
for seg in content_segments(item):
|
|
237
|
+
if first_str(seg.get("title")):
|
|
238
|
+
seg_title = first_str(seg.get("title"))
|
|
239
|
+
break
|
|
240
|
+
seg_title = re.sub(r"\s*>\s*", " › ", seg_title).strip("› ").strip()
|
|
241
|
+
if seg_title and seg_title != source["title"]:
|
|
242
|
+
source["doc_section"] = seg_title
|
|
243
|
+
source["chain_full"] = f"{source['title']} › {seg_title}"
|
|
244
|
+
else:
|
|
245
|
+
source["doc_section"] = ""
|
|
246
|
+
source["chain_full"] = ""
|
|
247
|
+
# 所属搜索条件(多路检索分组)与引用状态(未引用=接口召回但正文未采用)
|
|
248
|
+
source["search_key"] = first_str(item.get("搜索条件"), item.get("search_key"))
|
|
249
|
+
source["used"] = item.get("已引用", item.get("used", True))
|
|
250
|
+
if not isinstance(source["used"], bool):
|
|
251
|
+
source["used"] = True
|
|
252
|
+
# 发布日期可信度(实测:「高」=模型治理入库、标题模型精抽;「较高」=门户抓取、标题规则提取)
|
|
253
|
+
source["conf"] = first_str(item.get("发布日期可信度"), item.get("可信度"), item.get("confidence"))
|
|
231
254
|
key, label, css = normalize_kind(source["kind"])
|
|
232
255
|
source["type_key"] = key
|
|
233
256
|
source["type_label"] = label
|
|
@@ -283,17 +306,16 @@ def extract_sources(payload: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
|
283
306
|
sources: List[Dict[str, str]] = []
|
|
284
307
|
seen = set()
|
|
285
308
|
for item in raw_sources:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
sources.append(source)
|
|
309
|
+
# 一篇材料一张卡:段落合并为摘录(paragraph_text 拼接全部段落),不按段落拆卡——
|
|
310
|
+
# 溯源 JSON 的 materials 与正文角标按"材料"粒度一一对应,拆段会使编号错位。
|
|
311
|
+
source = source_from_article(item, len(sources) + 1)
|
|
312
|
+
key = (source["id"], source["title"], source["url"], source["excerpt"][:80])
|
|
313
|
+
if key in seen:
|
|
314
|
+
continue
|
|
315
|
+
seen.add(key)
|
|
316
|
+
if not source["id"]:
|
|
317
|
+
source["id"] = str(len(sources) + 1)
|
|
318
|
+
sources.append(source)
|
|
297
319
|
return sources
|
|
298
320
|
|
|
299
321
|
|
|
@@ -419,10 +441,13 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
419
441
|
"""核验报告单数据。只计算脚本真实可得的结果,不虚构通过。"""
|
|
420
442
|
generated_at = generated_at or datetime.now()
|
|
421
443
|
|
|
422
|
-
# ① 依据溯源:摘录可比对 +
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
444
|
+
# ① 依据溯源:摘录可比对 + 原文链接/知识专库可回看。
|
|
445
|
+
# 只统计被正文引用的材料——未引用召回材料未进入正文核验流程,其缺链在自身卡片上如实标注,
|
|
446
|
+
# 不应拖累"正文依据可交付"的报告级结论。
|
|
447
|
+
cited_sources = [s for s in sources if s.get("used", True)]
|
|
448
|
+
missing_links = [s["title"] for s in cited_sources if not s.get("has_link")]
|
|
449
|
+
missing_excerpts = [s["title"] for s in cited_sources if not (s.get("excerpt") or "").strip()]
|
|
450
|
+
trace_passed = len(cited_sources) - len(set(missing_links) | set(missing_excerpts))
|
|
426
451
|
|
|
427
452
|
# ② 引用绑定:正文角标与来源卡一一对应(按角标出现次数计,与用户在正文中数到的一致)
|
|
428
453
|
cited = citation_ids(answer)
|
|
@@ -465,29 +490,29 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
465
490
|
# 政策效力:无法自动判定现行效力,列出建议人工复核
|
|
466
491
|
policy_count = coverage.get("policy", 0)
|
|
467
492
|
|
|
468
|
-
trace_ok =
|
|
493
|
+
trace_ok = cited_sources and trace_passed == len(cited_sources)
|
|
469
494
|
binding_ok = (not unbound) and not no_citation
|
|
470
495
|
overall_passed = trace_ok and binding_ok
|
|
471
496
|
|
|
472
497
|
reasons = []
|
|
473
498
|
if not sources:
|
|
474
|
-
reasons.append("
|
|
499
|
+
reasons.append("没有找到来源材料")
|
|
475
500
|
if no_citation:
|
|
476
|
-
reasons.append("
|
|
501
|
+
reasons.append("正文里没有来源角标,对不上材料")
|
|
477
502
|
if missing_links:
|
|
478
503
|
reasons.append(f"{len(missing_links)} 条素材待补原文链接")
|
|
479
504
|
if unbound:
|
|
480
|
-
reasons.append(f"{len(unbound)}
|
|
505
|
+
reasons.append(f"有 {len(unbound)} 处角标找不到对应材料")
|
|
481
506
|
if self_check["status"] == "fail":
|
|
482
|
-
reasons.append("
|
|
507
|
+
reasons.append("交付前检查有没过的项")
|
|
483
508
|
|
|
484
509
|
return {
|
|
485
510
|
"overall": {
|
|
486
511
|
"passed": overall_passed,
|
|
487
|
-
"label": "
|
|
512
|
+
"label": "核验完成,正文依据逐条对过原文" if overall_passed else "核验未完全通过",
|
|
488
513
|
"reasons": reasons,
|
|
489
514
|
},
|
|
490
|
-
"traceability": {"total": len(
|
|
515
|
+
"traceability": {"total": len(cited_sources), "passed": trace_passed,
|
|
491
516
|
"missing_links": missing_links, "missing_excerpts": missing_excerpts},
|
|
492
517
|
"binding": {"total": len(all_marks), "bound": len(all_marks) - len(unbound), "unbound": unbound_ids, "no_citation": no_citation},
|
|
493
518
|
"freshness": freshness,
|
|
@@ -714,53 +739,54 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
|
|
|
714
739
|
|
|
715
740
|
bd = v["binding"]
|
|
716
741
|
if bd.get("no_citation"):
|
|
717
|
-
bd_html = (f'<div class="vi"><span class="s fail">✗
|
|
718
|
-
f'<span class="d"
|
|
742
|
+
bd_html = (f'<div class="vi"><span class="s fail">✗ 引用对应 0/0</span>'
|
|
743
|
+
f'<span class="d">正文里没有来源角标,{v["traceability"]["total"]} 条材料对不上正文</span></div>')
|
|
719
744
|
elif not bd["total"]:
|
|
720
|
-
bd_html = '<div class="vi"><span class="s none">—
|
|
745
|
+
bd_html = '<div class="vi"><span class="s none">— 引用对应 0/0</span><span class="d">正文里没有来源角标</span></div>'
|
|
721
746
|
elif not bd["unbound"]:
|
|
722
|
-
bd_html = (f'<div class="vi"><span class="s ok">✓
|
|
723
|
-
f'<span class="d"
|
|
747
|
+
bd_html = (f'<div class="vi"><span class="s ok">✓ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
|
|
748
|
+
f'<span class="d">正文每处 [n] 都能找到对应材料</span></div>')
|
|
724
749
|
else:
|
|
725
750
|
unbound_text = "、".join(f"[{esc(x)}]" for x in bd["unbound"][:8])
|
|
726
|
-
bd_html = (f'<div class="vi"><span class="s fail">✗
|
|
727
|
-
f'<span class="d"
|
|
751
|
+
bd_html = (f'<div class="vi"><span class="s fail">✗ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
|
|
752
|
+
f'<span class="d">对不上的角标 {unbound_text}</span></div>')
|
|
728
753
|
|
|
729
754
|
fr = v["freshness"]
|
|
730
755
|
if fr:
|
|
731
756
|
rng = f"{fr['min'][0]}-{fr['min'][1]:02d}~{fr['max'][0]}-{fr['max'][1]:02d}"
|
|
732
|
-
old = f"({fr['old_count']}
|
|
733
|
-
fr_html = f'<div class="vi"><span class="s ok">✓
|
|
757
|
+
old = f"({fr['old_count']} 条年头较久,按参考口径使用)" if fr["old_count"] else ""
|
|
758
|
+
fr_html = f'<div class="vi"><span class="s ok">✓ 材料新旧 已核</span><span class="d">材料日期 {esc(rng)}{esc(old)}</span></div>'
|
|
734
759
|
else:
|
|
735
|
-
fr_html = '<div class="vi"><span class="s none">—
|
|
760
|
+
fr_html = '<div class="vi"><span class="s none">— 材料新旧 未记录</span><span class="d">材料没标发布日期</span></div>'
|
|
736
761
|
|
|
737
762
|
cov = v["coverage"]
|
|
738
763
|
parts = [f"{KIND_CATALOG[k][0]} {cov[k]}" for k in ("policy", "data", "case", "reference") if cov.get(k)]
|
|
739
764
|
cov_state = "ok" if cov.get("policy") or cov.get("data") or cov.get("case") else "none"
|
|
740
|
-
cov_html = (f'<div class="vi"><span class="s {cov_state}">{"✓" if cov_state == "ok" else "—"}
|
|
741
|
-
f'<span class="d">{esc(" · ".join(parts)) if parts else "
|
|
765
|
+
cov_html = (f'<div class="vi"><span class="s {cov_state}">{"✓" if cov_state == "ok" else "—"} 材料构成</span>'
|
|
766
|
+
f'<span class="d">{esc(" · ".join(parts)) if parts else "材料没标类型"}</span></div>')
|
|
742
767
|
|
|
743
768
|
sc = v["self_check"]
|
|
744
769
|
if sc["status"] == "pass":
|
|
745
770
|
notes = ";".join(note for _, note in sc["items"].values() if note)
|
|
746
771
|
title_attr = f' title="{esc(notes)}"' if notes else ""
|
|
747
|
-
|
|
748
|
-
|
|
772
|
+
item_names = "、".join(sc["items"].keys()) if sc["items"] else "、".join(label for _, label in SELF_CHECK_ITEMS)
|
|
773
|
+
sc_html = (f'<div class="vi"><span class="s ok"{title_attr}>✓ 交付前检查 {sc["passed"]}/{sc["total"]}</span>'
|
|
774
|
+
f'<span class="d">{esc(item_names)}{esc(" · 悬停查看说明" if notes else "")}</span></div>')
|
|
749
775
|
elif sc["status"] == "fail":
|
|
750
776
|
failed_parts = []
|
|
751
777
|
for label, (status, note) in sc["items"].items():
|
|
752
778
|
if status != "pass":
|
|
753
779
|
suffix = f"({note[:40]}…)" if len(note) > 40 else (f"({note})" if note else "")
|
|
754
780
|
failed_parts.append(label + suffix)
|
|
755
|
-
sc_html = (f'<div class="vi"><span class="s fail">✗
|
|
756
|
-
f'<span class="d"
|
|
781
|
+
sc_html = (f'<div class="vi"><span class="s fail">✗ 交付前检查 {sc["passed"]}/{sc["total"]}</span>'
|
|
782
|
+
f'<span class="d">没过的项:{esc("、".join(failed_parts))}</span></div>')
|
|
757
783
|
else:
|
|
758
|
-
sc_html = '<div class="vi"><span class="s none">—
|
|
784
|
+
sc_html = '<div class="vi"><span class="s none">— 交付前检查 未记录</span><span class="d">本次溯源 JSON 没写入检查结果</span></div>'
|
|
759
785
|
|
|
760
786
|
manual = ""
|
|
761
787
|
if v["policy_count"]:
|
|
762
|
-
manual = (f'<div class="vi"><span class="s man">◐
|
|
763
|
-
f'<span class="d">{v["policy_count"]}
|
|
788
|
+
manual = (f'<div class="vi"><span class="s man">◐ 现行效力</span>'
|
|
789
|
+
f'<span class="d">{v["policy_count"]} 份政策文件建议按官方发布确认是否现行有效</span></div>')
|
|
764
790
|
|
|
765
791
|
return f"""
|
|
766
792
|
<div class="verify {state}">
|
|
@@ -769,7 +795,7 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
|
|
|
769
795
|
<div class="v-grid">
|
|
770
796
|
{tr_html}{bd_html}{fr_html}{cov_html}{sc_html}{manual}
|
|
771
797
|
</div>
|
|
772
|
-
<div class="v-note"
|
|
798
|
+
<div class="v-note">核验方式:先用深知可信搜索找权威来源,再把正文每处依据和原文逐条比对(都能点开原文回看),最后做了交付前五项检查。政策是否现行有效,以官方发布为准。{manual_checks_html}</div>
|
|
773
799
|
</div>"""
|
|
774
800
|
|
|
775
801
|
|
|
@@ -812,7 +838,12 @@ def render_section_cards(sections: List[Dict[str, Any]], sources: List[Dict[str,
|
|
|
812
838
|
|
|
813
839
|
|
|
814
840
|
def render_source_card(source: Dict[str, str]) -> str:
|
|
815
|
-
if source.get("
|
|
841
|
+
if not source.get("used", True):
|
|
842
|
+
# 未引用召回材料:不标"已核验"(未进入正文核验流程),只标可否查看
|
|
843
|
+
vk = ('<span class="sc-vk" style="color:var(--muted)">可查看原文</span>' if source.get("has_link")
|
|
844
|
+
else '<span class="sc-vk warn">待补链接</span>')
|
|
845
|
+
note_html = ""
|
|
846
|
+
elif source.get("verified"):
|
|
816
847
|
note = source.get("verify_note") or "摘录可比对,原文链接与知识专库可回看"
|
|
817
848
|
vk = f'<span class="sc-vk ok" title="{esc(note)}">✓ 已核验</span>'
|
|
818
849
|
note_html = f'<div class="sc-vnote">{esc(short(note, 90))}</div>' if source.get("verify_note") else ""
|
|
@@ -822,77 +853,86 @@ def render_source_card(source: Dict[str, str]) -> str:
|
|
|
822
853
|
note_html = ""
|
|
823
854
|
links = render_source_links(source.get("url"), source.get("policy_url", ""))
|
|
824
855
|
meta = " | ".join(v for v in [source.get("agency"), source.get("date"), source.get("area")] if v)
|
|
856
|
+
# 标题链:这段摘录在原文件中的章节标题(接口段落标题),悬停可见含文章标题的完整链
|
|
857
|
+
chain_html = (f'<div class="sc-chain" title="{esc("原文中的位置:" + source["chain_full"])}">'
|
|
858
|
+
f'标题:{esc(source["doc_section"])}</div>') if source.get("doc_section") else ""
|
|
825
859
|
section_html = f'<div class="sc-section">支撑:{esc(source["section"])}</div>' if source.get("section") else ""
|
|
860
|
+
# 高可信徽标:仅"发布日期可信度=高"(模型治理入库、标题模型精抽)的材料;"较高"(门户抓取)不标。
|
|
861
|
+
# 原文原段身份由摘录上方的"▍ 原文原段(非 AI 生成)"标注行承担,不在卡片头部重复挂标签。
|
|
862
|
+
conf_badge = ""
|
|
863
|
+
if source.get("conf") == "高":
|
|
864
|
+
conf_badge = ('<span class="sc-conf" title="发布日期可信度:高。内容经模型治理入库,'
|
|
865
|
+
'标题为模型从原文动态抽取,非规则提取">高可信</span>')
|
|
866
|
+
excerpt_tag = '<div class="sc-extag">▍ 原文原段(非 AI 生成)</div>'
|
|
867
|
+
# 已引用材料显示角标编号;未引用召回材料显示"未引用"灰标(不占正文角标号)
|
|
868
|
+
id_html = f'<span class="sc-id">[{esc(source["id"])}]</span>' if source.get("used", True) else '<span class="sc-unused">未引用</span>'
|
|
869
|
+
unused_attr = "" if source.get("used", True) else ' data-unused="1"'
|
|
826
870
|
return (
|
|
827
|
-
f'<article class="scard {source["type_css"]}" id="src-{esc(source["id"])}" data-type="{esc(source["type_key"])}" data-cite-id="{esc(source["id"])}">'
|
|
828
|
-
f'<div class="sc-head"
|
|
829
|
-
f'<span class="sc-type">{esc(source["type_label"])}</span>{vk}</div>'
|
|
871
|
+
f'<article class="scard {source["type_css"]}" id="src-{esc(source["id"])}" data-type="{esc(source["type_key"])}" data-cite-id="{esc(source["id"])}" data-search="{esc(source.get("search_key", ""))}"{unused_attr}>'
|
|
872
|
+
f'<div class="sc-head">{id_html}'
|
|
873
|
+
f'<span class="sc-type">{esc(source["type_label"])}</span>{conf_badge}{vk}</div>'
|
|
830
874
|
f'<h4>{esc(source.get("title"))}</h4>'
|
|
831
875
|
f'<div class="sc-meta">{esc(meta)}</div>'
|
|
832
|
-
f'{section_html}{note_html}'
|
|
876
|
+
f'{chain_html}{section_html}{note_html}'
|
|
877
|
+
f'{excerpt_tag}'
|
|
833
878
|
f'{render_excerpt_html(source.get("excerpt") or "接口返回中未识别到可展示的摘录。")}'
|
|
879
|
+
f'<div class="sc-more" role="button" tabindex="0"></div>'
|
|
834
880
|
f'{links}</article>'
|
|
835
881
|
)
|
|
836
882
|
|
|
837
883
|
|
|
838
|
-
def render_sources_panel(sources: List[Dict[str, str]], used: List[str]
|
|
884
|
+
def render_sources_panel(sources: List[Dict[str, str]], used: List[str]) -> str:
|
|
839
885
|
if not sources:
|
|
840
886
|
return '<aside class="sources"><h3>核验材料</h3><p class="empty">接口返回中未识别到可展示的材料。</p></aside>'
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
uncited = [s for s in sources if s["id"] not in used_set]
|
|
887
|
+
cited_cards = [render_source_card(s) for s in sources if s.get("used", True)]
|
|
888
|
+
uncited = [s for s in sources if not s.get("used", True)]
|
|
844
889
|
uncited_html = ""
|
|
845
890
|
if uncited:
|
|
846
891
|
uncited_cards = "".join(render_source_card(s) for s in uncited)
|
|
847
892
|
# 不用 <details> 折叠:部分宿主(WorkBuddy 等)的 HTML 预览服务会改写折叠区导致卡片丢失
|
|
848
893
|
uncited_html = (
|
|
849
894
|
'<div class="uncited-group"><div class="ug-title">未引用素材('
|
|
850
|
-
f'{len(uncited)}
|
|
895
|
+
f'{len(uncited)} 条 · 接口召回但正文未采用,供比对参考)</div>'
|
|
851
896
|
f'<div class="uncited-list">{uncited_cards}</div></div>'
|
|
852
897
|
)
|
|
853
898
|
verified_count = sum(1 for s in sources if s.get("verified"))
|
|
854
|
-
|
|
899
|
+
# 筛选维度 = 检索分组(多路检索时按来源分组,如"北京·AI政策/北京·产业数据"):胶囊样式沿用类型筛选样式,单选 + 全部。
|
|
900
|
+
# 类型不再作为筛选维度(卡片徽章已展示类型,且类型为模型主观标注)。
|
|
901
|
+
conds: List[Tuple[str, int]] = []
|
|
902
|
+
for s in sources:
|
|
903
|
+
key = s.get("search_key", "")
|
|
904
|
+
if not key:
|
|
905
|
+
continue
|
|
906
|
+
for i, (name, count) in enumerate(conds):
|
|
907
|
+
if name == key:
|
|
908
|
+
conds[i] = (name, count + 1)
|
|
909
|
+
break
|
|
910
|
+
else:
|
|
911
|
+
conds.append((key, 1))
|
|
855
912
|
filters_html = ""
|
|
856
|
-
if len(
|
|
857
|
-
buttons = ['<button class="on" data-
|
|
858
|
-
for
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
913
|
+
if len(conds) >= 2 or uncited:
|
|
914
|
+
buttons = ['<button class="on" data-cond="" type="button">全部</button>']
|
|
915
|
+
for name, count in conds:
|
|
916
|
+
buttons.append(f'<button data-cond="{esc(name)}" type="button">{esc(name)}({count})</button>')
|
|
917
|
+
if uncited:
|
|
918
|
+
buttons.append(f'<button data-cond="__unused__" type="button">未引用({len(uncited)})</button>')
|
|
919
|
+
filters_html = f'<div class="filters" role="group" aria-label="按检索分组筛选">{"".join(buttons)}</div>'
|
|
920
|
+
# "已核验"徽章只统计已引用材料(未引用召回未进入正文核验流程,不计入)
|
|
921
|
+
cited_sources = [s for s in sources if s.get("used", True)]
|
|
922
|
+
cited_verified = sum(1 for s in cited_sources if s.get("verified"))
|
|
923
|
+
badge = "全部已核验" if cited_sources and cited_verified == len(cited_sources) else f"{cited_verified}/{len(cited_sources)} 已核验"
|
|
863
924
|
return (
|
|
864
925
|
'<aside class="sources" id="sources-panel" aria-label="核验材料面板">'
|
|
865
926
|
'<a class="back-doc" href="#doc-top">↑ 返回核验报告单</a>'
|
|
866
|
-
f'<h3
|
|
927
|
+
f'<h3>核验材料(已引用 {len(cited_cards)} 条 · {esc(badge)})</h3>'
|
|
867
928
|
'<div class="src-tip">点击正文角标 [1] 定位材料原文并核对</div>'
|
|
868
929
|
f'{filters_html}'
|
|
869
930
|
'<input class="src-search" type="search" placeholder="搜索标题 / 来源 / 摘录…" aria-label="搜索来源">'
|
|
870
931
|
f'<div class="src-list">{"".join(cited_cards)}{uncited_html}</div>'
|
|
871
|
-
f'{kb_zone}'
|
|
872
932
|
'</aside>'
|
|
873
933
|
)
|
|
874
934
|
|
|
875
935
|
|
|
876
|
-
def render_kb_zone(kb_urls: List[str], kb_labels: List[str], source_count: int) -> str:
|
|
877
|
-
if not kb_urls:
|
|
878
|
-
return ""
|
|
879
|
-
chips = []
|
|
880
|
-
for index, url in enumerate(kb_urls):
|
|
881
|
-
label = kb_labels[index] if index < len(kb_labels) else "相关搜索来源"
|
|
882
|
-
chips.append(
|
|
883
|
-
f'<a class="kb-chip" href="{esc(url)}" target="_blank" rel="noopener">'
|
|
884
|
-
f'<span class="kb-label">{esc(label)}</span>'
|
|
885
|
-
f'<span class="kb-count">{"原始召回" if index else f"{source_count} 条来源"} · 可回看</span>'
|
|
886
|
-
'<span class="kb-arrow">打开 ↗</span></a>'
|
|
887
|
-
)
|
|
888
|
-
return (
|
|
889
|
-
'<div class="kb-zone"><div class="kb-title">原始召回存档(深知知识专库)</div>'
|
|
890
|
-
'<div class="kb-desc">以下链接可回看每次搜索的完整召回结果(含未写入正文的材料);'
|
|
891
|
-
'原文页面改版或下线时可回看当时召回的快照。逐条材料的核验请点击来源卡上的"查看原文"直达官方页面。</div>'
|
|
892
|
-
f'<div class="kb-list">{"".join(chips)}</div></div>'
|
|
893
|
-
)
|
|
894
|
-
|
|
895
|
-
|
|
896
936
|
def safe_output_filename(question: str, timestamp: datetime, fallback: str = "dknowc_search_trace", suffix_ext: str = ".html") -> str:
|
|
897
937
|
raw = question.strip() or fallback
|
|
898
938
|
normalized = re.sub(r"\s+", "_", raw)
|
|
@@ -911,8 +951,6 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
911
951
|
answer = normalize_citations(answer_override) if answer_override.strip() else extract_answer(payload)
|
|
912
952
|
sources = align_sources_to_answer(answer, extract_sources(payload))
|
|
913
953
|
used = citation_ids(answer)
|
|
914
|
-
kb_urls = extract_knowledge_bases(payload)
|
|
915
|
-
kb_labels = payload.get("knowledgeBaseLabels") if isinstance(payload.get("knowledgeBaseLabels"), list) else []
|
|
916
954
|
generated_at = generated_at or datetime.now()
|
|
917
955
|
generated = generated_at.strftime("%Y-%m-%d %H:%M")
|
|
918
956
|
|
|
@@ -928,7 +966,6 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
928
966
|
blocks, _ = parse_answer_blocks(answer, {s["id"] for s in sources})
|
|
929
967
|
doc_title, sections = group_sections(blocks)
|
|
930
968
|
display_title = doc_title or title
|
|
931
|
-
kb_zone = render_kb_zone(kb_urls, kb_labels, len(sources))
|
|
932
969
|
|
|
933
970
|
cov = verification["coverage"]
|
|
934
971
|
meta_bits = []
|
|
@@ -945,7 +982,7 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
945
982
|
<head>
|
|
946
983
|
<meta charset="utf-8">
|
|
947
984
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
948
|
-
<title>{esc(display_title)} ·
|
|
985
|
+
<title>{esc(display_title)} · 溯源核验报告</title>
|
|
949
986
|
<style>
|
|
950
987
|
:root{{
|
|
951
988
|
--navy:#0b1f3a; --ink:#172236; --muted:#667085; --line:#dce4ef; --line-strong:#b9c6d9;
|
|
@@ -969,6 +1006,9 @@ a{{color:var(--brand)}}
|
|
|
969
1006
|
/* 左栏 */
|
|
970
1007
|
.report{{min-width:0}}
|
|
971
1008
|
.r-head{{padding:22px 26px;background:#fff;border:1px solid var(--line);border-radius:12px;margin-bottom:16px;text-align:center}}
|
|
1009
|
+
.r-badge{{display:inline-flex;align-items:center;gap:14px;margin:0 0 6px;color:var(--navy);
|
|
1010
|
+
font-size:16px;font-weight:800;letter-spacing:7px;text-indent:7px;line-height:1.5}}
|
|
1011
|
+
.r-badge::before,.r-badge::after{{content:"";width:64px;border-top:1px solid var(--line-strong)}}
|
|
972
1012
|
.r-head h1{{margin:0 0 8px;font-size:22px;color:var(--navy);line-height:1.5}}
|
|
973
1013
|
.r-head .sub{{color:var(--muted);font-size:12.5px}}
|
|
974
1014
|
.warn-box{{margin:0 0 16px;padding:13px 16px;border:1.5px solid var(--danger);border-radius:10px;
|
|
@@ -1051,6 +1091,8 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1051
1091
|
.filters button{{border:1px solid var(--line);border-radius:999px;background:#fff;color:var(--muted);
|
|
1052
1092
|
padding:3px 11px;font-size:12px;cursor:pointer}}
|
|
1053
1093
|
.filters button.on{{background:var(--brand);border-color:var(--brand);color:#fff;font-weight:700}}
|
|
1094
|
+
.sc-unused{{font-size:10.5px;font-weight:800;color:var(--muted);background:#eef1f6;border-radius:4px;
|
|
1095
|
+
padding:1px 7px;flex:none}}
|
|
1054
1096
|
.src-search{{width:100%;padding:7px 10px;border:1px solid var(--line);border-radius:7px;font-size:12.5px;margin-bottom:12px}}
|
|
1055
1097
|
.scard{{border:1px solid var(--line);border-left-width:3px;border-radius:10px;padding:11px 13px;margin-bottom:10px;
|
|
1056
1098
|
background:#fff;transition:box-shadow .25s}}
|
|
@@ -1069,6 +1111,10 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1069
1111
|
.scard.cas .sc-type{{background:var(--case-soft);color:var(--case)}}
|
|
1070
1112
|
.sc-vk{{margin-left:auto;font-size:11px;font-weight:800;color:var(--ok)}}
|
|
1071
1113
|
.sc-vk.warn{{color:var(--warn)}}
|
|
1114
|
+
.sc-conf{{font-size:10.5px;font-weight:800;color:#8a5a00;background:var(--case-soft);border:1px solid #e8c98a;
|
|
1115
|
+
border-radius:4px;padding:0 7px;flex:none}}
|
|
1116
|
+
.sc-extag{{margin-top:8px;padding-top:7px;border-top:1px dashed var(--line-strong);font-size:11px;color:#0b6e4f;font-weight:700}}
|
|
1117
|
+
.sc-chain{{font-size:11.5px;color:var(--brand);margin-top:3px;font-weight:600;line-height:1.6;cursor:help}}
|
|
1072
1118
|
.scard h4{{margin:0 0 4px;font-size:13px;color:var(--navy);line-height:1.55}}
|
|
1073
1119
|
.sc-meta{{font-size:11.5px;color:var(--muted)}}
|
|
1074
1120
|
.sc-section{{font-size:11.5px;color:var(--brand);margin-top:3px;font-weight:600}}
|
|
@@ -1076,6 +1122,10 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1076
1122
|
.sc-excerpt{{margin:7px 0;padding:9px 10px;border-radius:7px;background:#f8fafc;color:#42566f;font-size:12px;line-height:1.7;
|
|
1077
1123
|
display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden;cursor:pointer}}
|
|
1078
1124
|
.scard.open .sc-excerpt{{display:block;-webkit-line-clamp:unset}}
|
|
1125
|
+
.sc-more{{display:none;margin:-3px 2px 4px;text-align:right;font-size:11px;color:var(--brand);font-weight:700;cursor:pointer;user-select:none}}
|
|
1126
|
+
.scard.clampable .sc-more{{display:block}}
|
|
1127
|
+
.scard.clampable .sc-more::before{{content:"展开全文 ▾"}}
|
|
1128
|
+
.scard.clampable.open .sc-more::before{{content:"收起 ▴"}}
|
|
1079
1129
|
.sc-excerpt.rich{{overflow-x:auto}}
|
|
1080
1130
|
.sc-excerpt.rich table{{width:max-content;min-width:100%;border-collapse:collapse;background:#fff;font-size:12px}}
|
|
1081
1131
|
.sc-excerpt.rich td,.sc-excerpt.rich th{{min-width:92px;max-width:220px;padding:7px 8px;border:1px solid var(--line);
|
|
@@ -1087,17 +1137,6 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1087
1137
|
.uncited-group{{margin-top:12px;border-top:1px dashed var(--line-strong);padding-top:10px}}
|
|
1088
1138
|
.ug-title{{font-size:12.5px;color:var(--muted);font-weight:700;line-height:1.6}}
|
|
1089
1139
|
.uncited-group .uncited-list{{margin-top:10px}}
|
|
1090
|
-
/* 知识专库 */
|
|
1091
|
-
.kb-zone{{margin-top:14px;border-top:1px dashed var(--line-strong);padding-top:12px}}
|
|
1092
|
-
.kb-title{{font-size:12.5px;font-weight:800;color:var(--navy)}}
|
|
1093
|
-
.kb-desc{{font-size:11.3px;color:var(--muted);line-height:1.65;margin:3px 0 8px}}
|
|
1094
|
-
.kb-list{{display:flex;flex-direction:column;gap:7px}}
|
|
1095
|
-
.kb-chip{{display:flex;align-items:center;gap:8px;padding:7px 10px;border:1px solid var(--line);border-radius:8px;
|
|
1096
|
-
background:#fbfcfe;text-decoration:none;font-size:11.5px}}
|
|
1097
|
-
.kb-chip:hover{{border-color:var(--brand);background:var(--brand-soft)}}
|
|
1098
|
-
.kb-label{{font-weight:700;color:#374151;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}
|
|
1099
|
-
.kb-count{{padding-left:8px;border-left:1px solid var(--line);color:var(--muted);white-space:nowrap}}
|
|
1100
|
-
.kb-arrow{{margin-left:auto;color:var(--brand);font-weight:700;white-space:nowrap}}
|
|
1101
1140
|
.empty{{color:var(--muted)}}
|
|
1102
1141
|
.foot{{text-align:center;color:var(--muted);font-size:11.5px;padding:16px 0 4px;line-height:1.8}}
|
|
1103
1142
|
@media (max-width:1020px){{
|
|
@@ -1115,6 +1154,8 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1115
1154
|
.layout{{grid-template-columns:1fr;padding:12px 10px 40px;gap:14px}}
|
|
1116
1155
|
.topbar{{padding:8px 12px;font-size:12px;gap:4px;flex-wrap:wrap}}
|
|
1117
1156
|
.topbar .tags span{{font-size:10.5px;padding:1px 8px;margin-left:4px}}
|
|
1157
|
+
.r-badge{{font-size:13.5px;letter-spacing:6px;text-indent:6px;gap:10px}}
|
|
1158
|
+
.r-badge::before,.r-badge::after{{width:40px}}
|
|
1118
1159
|
.r-head{{padding:16px 14px;border-radius:10px}}
|
|
1119
1160
|
.r-head h1{{font-size:18px}}
|
|
1120
1161
|
.r-head .sub{{font-size:11.5px;line-height:1.6}}
|
|
@@ -1137,9 +1178,9 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1137
1178
|
.ev-chip summary{{font-size:11px}}
|
|
1138
1179
|
.sources{{padding:12px;border-radius:10px}}
|
|
1139
1180
|
.scard{{padding:10px 11px}}
|
|
1181
|
+
.sc-extag{{font-size:10.5px}}
|
|
1182
|
+
.sc-chain{{font-size:11px}}
|
|
1140
1183
|
.sc-excerpt{{font-size:11.5px}}
|
|
1141
|
-
.kb-chip{{flex-wrap:wrap}}
|
|
1142
|
-
.kb-label{{white-space:normal}}
|
|
1143
1184
|
.mobile-nav{{display:block;margin:0 0 14px;padding:11px 14px;border:1.5px solid var(--brand);
|
|
1144
1185
|
border-radius:10px;background:var(--brand-soft);color:var(--brand);font-weight:800;
|
|
1145
1186
|
font-size:13.5px;text-decoration:none;text-align:center}}
|
|
@@ -1160,6 +1201,16 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1160
1201
|
font-size:12.5px;font-weight:700;padding:5px 14px;cursor:pointer}}
|
|
1161
1202
|
.sheet .scard{{box-shadow:none;margin-bottom:0}}
|
|
1162
1203
|
.sheet .sc-excerpt{{display:block;-webkit-line-clamp:unset;cursor:auto}}
|
|
1204
|
+
/* 正文表述 ↔ 原文原段 对照区(弹层顶部) */
|
|
1205
|
+
.cmp{{margin:0 0 10px;border:1px solid var(--line);border-radius:10px;overflow:hidden}}
|
|
1206
|
+
.cmp-tag{{font-size:11px;font-weight:800;padding:3px 10px}}
|
|
1207
|
+
.cmp-side{{padding:9px 12px;font-size:12.8px;line-height:1.7}}
|
|
1208
|
+
.cmp-side p{{margin:0}}
|
|
1209
|
+
.cmp-ai{{background:#fbfcfe;color:#374151}}
|
|
1210
|
+
.cmp-ai .cmp-tag{{background:#eef1f6;color:var(--ref)}}
|
|
1211
|
+
.cmp-src{{background:#f4faf7;color:#2f4a3e;border-top:1px dashed var(--line-strong)}}
|
|
1212
|
+
.cmp-src .cmp-tag{{background:var(--policy-soft);color:#0b6e4f}}
|
|
1213
|
+
.cmp-src .sc-excerpt{{display:block;-webkit-line-clamp:unset;background:#fff;cursor:auto;font-size:12px;padding:8px 10px;margin:0}}
|
|
1163
1214
|
}}
|
|
1164
1215
|
@media print{{
|
|
1165
1216
|
.topbar,.filters,.src-search{{display:none!important}}
|
|
@@ -1177,7 +1228,7 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1177
1228
|
<body>
|
|
1178
1229
|
|
|
1179
1230
|
<header class="topbar">
|
|
1180
|
-
<div class="tb-title">{esc(display_title)} ·
|
|
1231
|
+
<div class="tb-title">{esc(display_title)} · 溯源核验报告</div>
|
|
1181
1232
|
<div class="tags">
|
|
1182
1233
|
<span>生成于 {esc(generated)}</span>
|
|
1183
1234
|
<span>素材来源:深知可信搜索</span>
|
|
@@ -1187,6 +1238,7 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1187
1238
|
<div class="layout">
|
|
1188
1239
|
<main class="report" aria-label="核验报告正文">
|
|
1189
1240
|
<div class="r-head" id="doc-top">
|
|
1241
|
+
<div class="r-badge">溯源核验报告</div>
|
|
1190
1242
|
<h1>{esc(display_title)}</h1>
|
|
1191
1243
|
<div class="sub">{esc(meta_line)}</div>
|
|
1192
1244
|
</div>
|
|
@@ -1194,15 +1246,15 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1194
1246
|
{render_verify_panel(verification)}
|
|
1195
1247
|
<a class="mobile-nav" href="#sources-panel">查看核验材料({len(sources)} 条 · 点击角标可定位原文)↓</a>
|
|
1196
1248
|
{render_section_cards(sections, sources)}
|
|
1197
|
-
<div class="foot">深知公文写作 ·
|
|
1249
|
+
<div class="foot">深知公文写作 · 溯源核验报告 | 内容由 AI 生成,仅供参考,政策现行效力以官方发布为准</div>
|
|
1198
1250
|
</main>
|
|
1199
|
-
{render_sources_panel(sources, used
|
|
1251
|
+
{render_sources_panel(sources, used)}
|
|
1200
1252
|
</div>
|
|
1201
1253
|
|
|
1202
1254
|
<div class="sheet-mask" aria-hidden="true"></div>
|
|
1203
1255
|
<div class="sheet" role="dialog" aria-label="核验材料">
|
|
1204
1256
|
<div class="sheet-grab"></div>
|
|
1205
|
-
<div class="sheet-head"><b
|
|
1257
|
+
<div class="sheet-head"><b>依据对照</b><button class="sheet-close" type="button">收起</button></div>
|
|
1206
1258
|
<div class="sheet-body"></div>
|
|
1207
1259
|
</div>
|
|
1208
1260
|
|
|
@@ -1216,20 +1268,41 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1216
1268
|
if (id) byId[id] = c;
|
|
1217
1269
|
}});
|
|
1218
1270
|
|
|
1219
|
-
/*
|
|
1271
|
+
/* 移动端底部弹层:点角标就地展示"正文表述 ↔ 原文原段"对照 + 材料卡,不打断正文阅读 */
|
|
1220
1272
|
var sheet = document.querySelector(".sheet");
|
|
1221
1273
|
var mask = document.querySelector(".sheet-mask");
|
|
1222
1274
|
function isMobile() {{
|
|
1223
1275
|
return window.matchMedia("(max-width:680px)").matches;
|
|
1224
1276
|
}}
|
|
1225
|
-
function
|
|
1277
|
+
function escHtml(s) {{
|
|
1278
|
+
var d = document.createElement("div");
|
|
1279
|
+
d.textContent = s;
|
|
1280
|
+
return d.innerHTML;
|
|
1281
|
+
}}
|
|
1282
|
+
function sentenceOf(el) {{
|
|
1283
|
+
var para = el && el.closest ? el.closest(".doc-block,.doc-item") : null;
|
|
1284
|
+
return para && para.querySelector("p") ? para.querySelector("p").innerText.trim() : "";
|
|
1285
|
+
}}
|
|
1286
|
+
function openSheet(card, sentence) {{
|
|
1226
1287
|
if (!sheet) return;
|
|
1227
1288
|
var body = sheet.querySelector(".sheet-body");
|
|
1289
|
+
body.innerHTML = "";
|
|
1290
|
+
if (sentence) {{
|
|
1291
|
+
var excerpt = card.querySelector(".sc-excerpt");
|
|
1292
|
+
var cmp = document.createElement("div");
|
|
1293
|
+
cmp.className = "cmp";
|
|
1294
|
+
cmp.innerHTML =
|
|
1295
|
+
'<div class="cmp-side cmp-ai"><div class="cmp-tag">正文表述(AI 生成)</div><p>' + escHtml(sentence) + '</p></div>' +
|
|
1296
|
+
'<div class="cmp-side cmp-src"><div class="cmp-tag">原文原段(非 AI 生成)</div>' +
|
|
1297
|
+
'<div class="sc-excerpt">' + (excerpt ? excerpt.innerHTML : "") + '</div></div>';
|
|
1298
|
+
body.appendChild(cmp);
|
|
1299
|
+
}}
|
|
1228
1300
|
var clone = card.cloneNode(true);
|
|
1229
1301
|
clone.removeAttribute("id");
|
|
1230
1302
|
clone.classList.remove("hide");
|
|
1231
1303
|
clone.classList.add("open");
|
|
1232
|
-
|
|
1304
|
+
var sheetMore = clone.querySelector(".sc-more");
|
|
1305
|
+
if (sheetMore) sheetMore.remove();
|
|
1233
1306
|
body.appendChild(clone);
|
|
1234
1307
|
sheet.classList.add("show");
|
|
1235
1308
|
mask.classList.add("show");
|
|
@@ -1260,7 +1333,7 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1260
1333
|
return;
|
|
1261
1334
|
}}
|
|
1262
1335
|
if (isMobile()) {{
|
|
1263
|
-
openSheet(card);
|
|
1336
|
+
openSheet(card, sentenceOf(btn));
|
|
1264
1337
|
return;
|
|
1265
1338
|
}}
|
|
1266
1339
|
card.classList.remove("hide", "open");
|
|
@@ -1270,25 +1343,42 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1270
1343
|
}});
|
|
1271
1344
|
}});
|
|
1272
1345
|
|
|
1273
|
-
/*
|
|
1346
|
+
/* 摘录点击展开/收起:内容被截断(超出 4 行)的卡片显示"展开全文"引导,
|
|
1347
|
+
未截断的短摘录不显示,避免误导 */
|
|
1274
1348
|
cards.forEach(function (c) {{
|
|
1275
1349
|
var ex = c.querySelector(".sc-excerpt");
|
|
1276
1350
|
if (!ex) return;
|
|
1351
|
+
if (ex.scrollHeight > ex.clientHeight + 4) c.classList.add("clampable");
|
|
1352
|
+
var more = c.querySelector(".sc-more");
|
|
1353
|
+
function toggleExcerpt() {{ c.classList.toggle("open"); }}
|
|
1277
1354
|
ex.addEventListener("click", function (e) {{
|
|
1278
1355
|
if (e.target.closest("a")) return;
|
|
1279
|
-
|
|
1356
|
+
toggleExcerpt();
|
|
1280
1357
|
}});
|
|
1358
|
+
if (more) {{
|
|
1359
|
+
more.addEventListener("click", toggleExcerpt);
|
|
1360
|
+
more.addEventListener("keydown", function (e) {{
|
|
1361
|
+
if (e.key === "Enter" || e.key === " ") {{ e.preventDefault(); toggleExcerpt(); }}
|
|
1362
|
+
}});
|
|
1363
|
+
}}
|
|
1281
1364
|
}});
|
|
1282
1365
|
|
|
1283
|
-
/* 证据 chips
|
|
1366
|
+
/* 证据 chips(灰框):桌面端点击就地展开并高亮右栏来源卡;手机端不就地展开,点击直接弹出底部材料弹层。
|
|
1367
|
+
展开锁定:浏览器(Chrome 系)对 <details> 展开会自动滚动露出内容、收起时滚动位置会被回夹,
|
|
1368
|
+
点击时锁定滚动位置并在展开/收起后滚回,消除页面"轻微滚动"感。 */
|
|
1284
1369
|
document.querySelectorAll(".ev-chip").forEach(function (chip) {{
|
|
1285
1370
|
var summary = chip.querySelector("summary");
|
|
1286
1371
|
if (summary) {{
|
|
1287
1372
|
summary.addEventListener("click", function (e) {{
|
|
1288
|
-
if (
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1373
|
+
if (isMobile()) {{
|
|
1374
|
+
e.preventDefault();
|
|
1375
|
+
var card = byId[chip.getAttribute("data-cite")];
|
|
1376
|
+
if (card) openSheet(card, sentenceOf(chip));
|
|
1377
|
+
return;
|
|
1378
|
+
}}
|
|
1379
|
+
var y = window.scrollY;
|
|
1380
|
+
var restore = function () {{ window.scrollTo(0, y); }};
|
|
1381
|
+
requestAnimationFrame(function () {{ restore(); requestAnimationFrame(restore); }});
|
|
1292
1382
|
}});
|
|
1293
1383
|
}}
|
|
1294
1384
|
chip.addEventListener("toggle", function () {{
|
|
@@ -1301,21 +1391,23 @@ code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
|
1301
1391
|
}});
|
|
1302
1392
|
}});
|
|
1303
1393
|
|
|
1304
|
-
/*
|
|
1305
|
-
var
|
|
1394
|
+
/* 检索分组筛选(单选 + 全部 + 未引用,胶囊样式)+ 关键字搜索叠加 */
|
|
1395
|
+
var cond = "";
|
|
1306
1396
|
var kw = "";
|
|
1307
1397
|
function apply() {{
|
|
1308
1398
|
cards.forEach(function (c) {{
|
|
1309
|
-
var
|
|
1399
|
+
var okCond = !cond;
|
|
1400
|
+
if (cond === "__unused__") okCond = c.getAttribute("data-unused") === "1";
|
|
1401
|
+
else if (cond) okCond = c.getAttribute("data-search") === cond;
|
|
1310
1402
|
var okKw = !kw || (c.textContent || "").toLowerCase().indexOf(kw) !== -1;
|
|
1311
|
-
c.classList.toggle("hide", !(
|
|
1403
|
+
c.classList.toggle("hide", !(okCond && okKw));
|
|
1312
1404
|
}});
|
|
1313
1405
|
}}
|
|
1314
1406
|
document.querySelectorAll(".filters button").forEach(function (b) {{
|
|
1315
1407
|
b.addEventListener("click", function () {{
|
|
1316
1408
|
document.querySelectorAll(".filters button").forEach(function (x) {{ x.classList.remove("on"); }});
|
|
1317
1409
|
b.classList.add("on");
|
|
1318
|
-
|
|
1410
|
+
cond = b.getAttribute("data-cond") || "";
|
|
1319
1411
|
apply();
|
|
1320
1412
|
}});
|
|
1321
1413
|
}});
|
|
@@ -1345,19 +1437,22 @@ def align_sources_to_answer(answer: str, sources: List[Dict[str, str]]) -> List[
|
|
|
1345
1437
|
return aligned
|
|
1346
1438
|
|
|
1347
1439
|
|
|
1348
|
-
|
|
1349
|
-
|
|
1440
|
+
|
|
1441
|
+
def _dsh_default_output_dir() -> str:
|
|
1442
|
+
"""dsh:未显式传 --output 时,默认输出到会话产物目录 official-docs/output/。"""
|
|
1350
1443
|
import os as _os
|
|
1351
1444
|
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
1352
1445
|
if not _ws:
|
|
1353
1446
|
_sid = _os.environ.get("DSH_SESSION_ID", "")
|
|
1354
1447
|
_ws = str(Path.cwd() / "dknowc-output" / (_sid[:8] if _sid else "_default"))
|
|
1355
|
-
|
|
1448
|
+
return str(Path(_ws).resolve() / "official-docs" / "output")
|
|
1449
|
+
|
|
1356
1450
|
|
|
1451
|
+
def main() -> None:
|
|
1357
1452
|
parser = argparse.ArgumentParser(description="生成可信溯源核验报告 HTML")
|
|
1358
1453
|
parser.add_argument("input_json", help="结构化溯源 JSON 或搜索结果 JSON")
|
|
1359
1454
|
parser.add_argument("--output", help="输出 HTML 路径;不传时根据问题自动生成短文件名")
|
|
1360
|
-
parser.add_argument("--output-dir", default=
|
|
1455
|
+
parser.add_argument("--output-dir", default=_dsh_default_output_dir(), help="未传 --output 时的输出目录")
|
|
1361
1456
|
parser.add_argument("--title", default="可信溯源核验报告", help="页面标题")
|
|
1362
1457
|
parser.add_argument("--answer-file", help="最终正文文件。复杂任务综合后必须传入,确保 HTML 展示的正文与交付一致。")
|
|
1363
1458
|
parser.add_argument("--clean-md-output", help="输出干净 Markdown 路径;内容来自同一份最终答案,并移除 [1]、【1】等溯源角标。")
|