dknowc-dsh 2.3.1 → 2.4.1
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/README.md +11 -3
- package/cordis.patch.yml +1 -1
- package/package.json +7 -4
- package/skills/dk-trace-report/SKILL.md +288 -0
- package/skills/dk-trace-report/config/examples/doc.json +56 -0
- package/skills/dk-trace-report/config/examples/legal.json +51 -0
- package/skills/dk-trace-report/config/examples/ppt.json +47 -0
- package/skills/dk-trace-report/config/examples/tax.json +46 -0
- package/skills/dk-trace-report/config/examples/trusted.json +122 -0
- package/skills/dk-trace-report/reference/sample_input.json +60 -0
- package/skills/dk-trace-report/resources/ECHARTS-NOTICE.txt +10 -0
- package/skills/dk-trace-report/resources/echarts.custom.min.js +48 -0
- package/skills/dk-trace-report/scripts/build_report_input.py +333 -0
- package/skills/{dknowc-trusted-search → dk-trace-report}/scripts/chart_embed.py +4 -1
- package/skills/{dknowc-trusted-search → dk-trace-report}/scripts/render_trace_html.py +1071 -536
- package/skills/dk-trace-report/scripts/run_paths.py +95 -0
- package/skills/dk-trace-report/scripts/trust_digest.py +77 -0
- package/skills/dknowc-legal-assistant/README.md +95 -0
- package/skills/dknowc-legal-assistant/SKILL.md +122 -0
- package/skills/dknowc-legal-assistant/attribution.json +5 -0
- package/skills/dknowc-legal-assistant/reference/answer-and-report.md +221 -0
- package/skills/dknowc-legal-assistant/reference/capability-layer.md +143 -0
- package/skills/dknowc-legal-assistant/reference/legal_claims.example.json +96 -0
- package/skills/dknowc-legal-assistant/reference/onboarding_scripts.md +198 -0
- package/skills/dknowc-legal-assistant/reference/policy_tags.json +2002 -0
- package/skills/dknowc-legal-assistant/reference/retrieval-statute.md +81 -0
- package/skills/dknowc-legal-assistant/reference/retrieval-v2.md +133 -0
- package/skills/dknowc-legal-assistant/reference/sample_search_result.md +33 -0
- package/skills/dknowc-legal-assistant/reference/sample_trace_report.html +940 -0
- package/skills/dknowc-legal-assistant/reference/tags.md +53 -0
- package/skills/dknowc-legal-assistant/reference/troubleshooting.md +50 -0
- package/skills/dknowc-legal-assistant/reference/verification-pass.md +59 -0
- package/skills/dknowc-legal-assistant/resources/echarts.custom.min.js +48 -0
- package/skills/dknowc-legal-assistant/scripts/api_key.py +68 -0
- package/skills/dknowc-legal-assistant/scripts/attribution.py +61 -0
- package/skills/dknowc-legal-assistant/scripts/calc_legal.py +375 -0
- package/skills/dknowc-legal-assistant/scripts/calc_period.py +155 -0
- package/skills/dknowc-legal-assistant/scripts/check_answer.py +664 -0
- package/skills/dknowc-legal-assistant/scripts/initialize.py +188 -0
- package/skills/dknowc-legal-assistant/scripts/legal_client.py +208 -0
- package/skills/dknowc-legal-assistant/scripts/legal_search.py +1059 -0
- package/skills/dknowc-legal-assistant/scripts/merge_search_results.py +630 -0
- package/skills/dknowc-legal-assistant/scripts/path_guard.py +92 -0
- package/skills/dknowc-legal-assistant/scripts/question_profile.py +215 -0
- package/skills/dknowc-legal-assistant/scripts/register_key.mjs +1152 -0
- package/skills/dknowc-legal-assistant/scripts/run_eval.py +109 -0
- package/skills/dknowc-legal-assistant/scripts/source_cards.py +321 -0
- package/skills/dknowc-legal-assistant/scripts/tag_catalog.py +162 -0
- package/skills/dknowc-legal-assistant/scripts/trace_report.config.json +66 -0
- package/skills/dknowc-legal-assistant/scripts/verify_claims.py +448 -0
- package/skills/dknowc-legal-assistant/scripts/websearch_convert.py +396 -0
- package/skills/dknowc-official-doc-writer/README.md +32 -21
- package/skills/dknowc-official-doc-writer/SKILL.md +28 -15
- package/skills/dknowc-official-doc-writer/config/trace_report.config.json +56 -0
- package/skills/dknowc-official-doc-writer/reference/anti_ai_patterns.md +14 -2
- package/skills/dknowc-official-doc-writer/reference/fact_discipline.md +4 -0
- package/skills/dknowc-official-doc-writer/reference/genre_writing_notes.md +4 -0
- package/skills/dknowc-official-doc-writer/reference/initialization.md +13 -8
- package/skills/dknowc-official-doc-writer/reference/local_memory_guide.md +7 -7
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +21 -0
- package/skills/dknowc-official-doc-writer/reference/materials_pipeline.md +64 -7
- package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/outline_rules.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +13 -13
- package/skills/dknowc-official-doc-writer/reference/research_notes.md +5 -3
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +6 -2
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +44 -32
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +63 -36
- package/skills/dknowc-official-doc-writer/reference/standards/01_report.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/02_qingshi.md +6 -3
- package/skills/dknowc-official-doc-writer/reference/standards/03_pifu.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/04_tongzhi.md +12 -3
- package/skills/dknowc-official-doc-writer/reference/standards/05_yijian.md +8 -2
- package/skills/dknowc-official-doc-writer/reference/standards/06_han.md +2 -2
- 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 +1 -1
- 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/standards/25_plan.md +2 -1
- package/skills/dknowc-official-doc-writer/reference/standards/26_summary.md +7 -1
- package/skills/dknowc-official-doc-writer/reference/standards/27_speech.md +4 -1
- package/skills/dknowc-official-doc-writer/reference/standards/99_expressions.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/task_router.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/working_principles.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/writing_method.md +166 -0
- package/skills/dknowc-official-doc-writer/reference/writing_rules.md +10 -4
- package/skills/dknowc-official-doc-writer/scripts/api_key.py +24 -25
- package/skills/dknowc-official-doc-writer/scripts/attribution.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/build_trace_json.py +205 -13
- package/skills/dknowc-official-doc-writer/scripts/check_materials.py +367 -22
- package/skills/dknowc-official-doc-writer/scripts/deep_convert.py +5 -0
- package/skills/dknowc-official-doc-writer/scripts/deep_query.py +2 -1
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +20 -7
- package/skills/dknowc-official-doc-writer/scripts/extract_reference.py +1 -0
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +88 -30
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +232 -6
- package/skills/dknowc-official-doc-writer/scripts/local_memory.py +2 -6
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +100 -7
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +2 -1
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +265 -32
- package/skills/dknowc-official-doc-writer/scripts/review_document.py +1 -0
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +117 -10
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +1 -0
- package/skills/dknowc-official-doc-writer/scripts/update_skill.py +339 -0
- package/skills/dknowc-official-doc-writer/scripts/websearch_convert.py +326 -0
- package/skills/dknowc-ppt-assistant/README.md +7 -9
- package/skills/dknowc-ppt-assistant/SKILL.md +28 -19
- package/skills/dknowc-ppt-assistant/config/trace_report.config.json +65 -0
- package/skills/dknowc-ppt-assistant/references/initialization.md +20 -8
- package/skills/dknowc-ppt-assistant/references/material_usage.md +46 -9
- package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +7 -5
- package/skills/dknowc-ppt-assistant/references/sample_trace_report.html +372 -920
- package/skills/dknowc-ppt-assistant/references/search_intro.md +2 -2
- package/skills/dknowc-ppt-assistant/references/svg-authoring.md +2 -2
- package/skills/dknowc-ppt-assistant/scripts/api_key.py +5 -28
- package/skills/dknowc-ppt-assistant/scripts/build_trace_input.py +188 -0
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +238 -3
- package/skills/dknowc-ppt-assistant/scripts/mcp_convert.py +1 -10
- package/skills/dknowc-ppt-assistant/scripts/merge_search_results.py +604 -0
- package/skills/dknowc-ppt-assistant/scripts/preview_slide_html.py +4 -11
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +224 -63
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +29 -12
- package/skills/dknowc-ppt-assistant/scripts/update_skill.py +314 -0
- package/skills/dknowc-ppt-assistant/scripts/websearch_convert.py +326 -0
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +92 -29
- package/skills/dknowc-ppt-assistant/workflows/routing.md +1 -1
- package/skills/dknowc-tax-assistant/README.md +54 -0
- package/skills/dknowc-tax-assistant/SKILL.md +99 -0
- package/skills/dknowc-tax-assistant/attribution.json +5 -0
- package/skills/dknowc-tax-assistant/reference/answer-and-report.md +100 -0
- package/skills/dknowc-tax-assistant/reference/capability-layer.md +205 -0
- package/skills/dknowc-tax-assistant/reference/onboarding_scripts.md +68 -0
- package/skills/dknowc-tax-assistant/reference/policy_tags.json +2002 -0
- package/skills/dknowc-tax-assistant/reference/retrieval-policy.md +43 -0
- package/skills/dknowc-tax-assistant/reference/retrieval-v2.md +58 -0
- package/skills/dknowc-tax-assistant/reference/tags.md +53 -0
- package/skills/dknowc-tax-assistant/reference/tax_claims.example.json +76 -0
- package/skills/dknowc-tax-assistant/reference/trace_report.config.json +46 -0
- package/skills/dknowc-tax-assistant/reference/troubleshooting.md +70 -0
- package/skills/dknowc-tax-assistant/reference/websearch-fallback.md +59 -0
- package/skills/dknowc-tax-assistant/resources/THIRD_PARTY_NOTICES.md +9 -0
- package/skills/dknowc-tax-assistant/resources/echarts.custom.min.js +48 -0
- package/skills/dknowc-tax-assistant/scripts/api_key.py +60 -0
- package/skills/dknowc-tax-assistant/scripts/attribution.py +61 -0
- package/skills/dknowc-tax-assistant/scripts/calc_period.py +156 -0
- package/skills/dknowc-tax-assistant/scripts/calc_tax.py +179 -0
- package/skills/dknowc-tax-assistant/scripts/check_answer.py +210 -0
- package/skills/dknowc-tax-assistant/scripts/initialize.py +208 -0
- package/skills/dknowc-tax-assistant/scripts/merge_search_results.py +631 -0
- package/skills/dknowc-tax-assistant/scripts/path_guard.py +23 -0
- package/skills/dknowc-tax-assistant/scripts/question_profile.py +444 -0
- package/skills/dknowc-tax-assistant/scripts/register_key.mjs +1173 -0
- package/skills/dknowc-tax-assistant/scripts/run_dir.py +149 -0
- package/skills/dknowc-tax-assistant/scripts/source_cards.py +372 -0
- package/skills/dknowc-tax-assistant/scripts/tag_catalog.py +164 -0
- package/skills/dknowc-tax-assistant/scripts/tax_client.py +218 -0
- package/skills/dknowc-tax-assistant/scripts/tax_search.py +403 -0
- package/skills/dknowc-tax-assistant/scripts/verify_claims.py +587 -0
- package/skills/dknowc-tax-assistant/scripts/websearch_convert.py +352 -0
- package/skills/dknowc-trusted-search/README.md +25 -19
- package/skills/dknowc-trusted-search/SKILL.md +205 -73
- package/skills/dknowc-trusted-search/config/trace_report.config.json +119 -0
- package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +3 -3
- package/skills/dknowc-trusted-search/reference/sample_trace_report.html +286 -191
- package/skills/dknowc-trusted-search/resources/ECHARTS-NOTICE.txt +10 -0
- package/skills/dknowc-trusted-search/scripts/api_key.py +0 -1
- package/skills/dknowc-trusted-search/scripts/attribution.py +1 -1
- package/skills/dknowc-trusted-search/scripts/build_trace_input.py +173 -0
- package/skills/dknowc-trusted-search/scripts/deep_convert.py +79 -30
- package/skills/dknowc-trusted-search/scripts/deep_query.py +22 -33
- package/skills/dknowc-trusted-search/scripts/initialize.py +343 -2
- package/skills/dknowc-trusted-search/scripts/merge_search_results.py +222 -35
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +241 -29
- package/skills/dknowc-trusted-search/scripts/source_display.py +59 -0
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +67 -34
- package/skills/dknowc-trusted-search/scripts/update_skill.py +300 -0
- package/skills/dknowc-trusted-search/scripts/websearch_convert.py +328 -0
- package/src/index.js +18 -2
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +0 -2574
- package/skills/dknowc-ppt-assistant/official-docs/output/.gitkeep +0 -0
- package/skills/dknowc-ppt-assistant/official-docs/search-results/.gitkeep +0 -0
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +0 -2642
- package/skills/dknowc-trusted-search/official-docs/output/.gitkeep +0 -0
- package/skills/dknowc-trusted-search/official-docs/search-results/.gitkeep +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""运行目录(run dir)管理:所有业务产物只写会话工作区里的独立运行目录。
|
|
3
|
+
|
|
4
|
+
口径(对齐可信多引擎搜索 1.0.1):
|
|
5
|
+
- 检索 JSON、答案、报告、补查/重渲染产物统一写到 `--out` / `--run` 指定的运行目录;
|
|
6
|
+
- 任何输出都拒绝落在 Skill 安装目录内(含 official-docs/),不默认创建
|
|
7
|
+
official-docs/search-results、official-docs/output;
|
|
8
|
+
- 首次检索用 new_run_dir():目录已存在且非空即报错,避免并行/重复运行互相覆盖;
|
|
9
|
+
- 下游(合并、渲染、补查、画像/校验)用 open_run_dir():必须是已存在的运行目录;
|
|
10
|
+
- 都不传时 auto_run_dir() 在当前工作目录的 runs/ 下新建唯一名;当前目录若在
|
|
11
|
+
Skill 安装目录内则拒绝(干净安装后不能往 Skill 目录落任何业务文件)。
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import re
|
|
17
|
+
import time
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def is_skill_path(path: Path) -> bool:
|
|
24
|
+
path = Path(path)
|
|
25
|
+
return path == SKILL_ROOT or SKILL_ROOT in path.parents
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _resolve(value: str) -> Path:
|
|
29
|
+
raw = Path(str(value or "")).expanduser()
|
|
30
|
+
if not raw.is_absolute():
|
|
31
|
+
raw = Path.cwd() / raw
|
|
32
|
+
return raw.resolve()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _reject_skill_path(path: Path, flag: str) -> None:
|
|
36
|
+
if is_skill_path(path):
|
|
37
|
+
raise ValueError(
|
|
38
|
+
f"{flag} 不能指向 Skill 安装目录内:{path}\n"
|
|
39
|
+
"请使用当前会话工作区的独立运行目录,例如 ./runs/20261120-B01-<时间>,"
|
|
40
|
+
"避免污染安装目录、并行任务互相覆盖。"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def new_run_dir(value: str, flag: str = "--out") -> Path:
|
|
45
|
+
"""新建运行目录:已存在且非空即拒绝(不覆盖已有 run)。"""
|
|
46
|
+
path = _resolve(value)
|
|
47
|
+
_reject_skill_path(path, flag)
|
|
48
|
+
if path.exists() and any(path.iterdir()):
|
|
49
|
+
raise ValueError(
|
|
50
|
+
f"{flag} 目录已有运行结果:{path}\n"
|
|
51
|
+
"请为本次运行使用独立目录,或先清理该目录。"
|
|
52
|
+
)
|
|
53
|
+
path.mkdir(parents=True, exist_ok=True)
|
|
54
|
+
return path
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def open_run_dir(value: str, flag: str = "--run") -> Path:
|
|
58
|
+
"""打开已有运行目录(合并/渲染/补查/画像校验用):必须存在且不在 Skill 目录内。"""
|
|
59
|
+
path = _resolve(value)
|
|
60
|
+
_reject_skill_path(path, flag)
|
|
61
|
+
if not path.is_dir():
|
|
62
|
+
raise ValueError(f"{flag} 不是已存在的运行目录:{path}")
|
|
63
|
+
return path
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def ensure_run_dir(value: str, flag: str = "--out") -> Path:
|
|
67
|
+
"""画像/材料/校验等上游脚本用:目录存在就复用,不存在就新建(不要求先跑检索)。"""
|
|
68
|
+
path = _resolve(value)
|
|
69
|
+
_reject_skill_path(path, flag)
|
|
70
|
+
if path.exists() and not path.is_dir():
|
|
71
|
+
raise ValueError(f"{flag} 已存在但不是目录:{path}")
|
|
72
|
+
path.mkdir(parents=True, exist_ok=True)
|
|
73
|
+
return path
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def auto_run_dir(prefix: str = "tax") -> Path:
|
|
77
|
+
"""未传 --out 时的默认运行目录:当前工作目录 runs/<prefix>-<时间>。"""
|
|
78
|
+
cwd = Path.cwd().resolve()
|
|
79
|
+
_reject_skill_path(cwd, "当前工作目录")
|
|
80
|
+
stamp = time.strftime("%Y%m%d-%H%M%S")
|
|
81
|
+
base = cwd / "runs" / f"{prefix}-{stamp}"
|
|
82
|
+
path = base
|
|
83
|
+
seq = 1
|
|
84
|
+
while path.exists() and any(path.iterdir()):
|
|
85
|
+
path = Path(f"{base}-{seq}")
|
|
86
|
+
seq += 1
|
|
87
|
+
path.mkdir(parents=True, exist_ok=True)
|
|
88
|
+
return path
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def out_file(run_dir: Path, name: str, flag: str = "--output") -> Path:
|
|
92
|
+
"""运行目录内的输出文件:只接受文件名,拒绝路径穿越与绝对路径。"""
|
|
93
|
+
raw = str(name or "").strip()
|
|
94
|
+
if not raw:
|
|
95
|
+
raise ValueError(f"{flag} 不能为空")
|
|
96
|
+
candidate = Path(raw)
|
|
97
|
+
if candidate.is_absolute() or len(candidate.parts) > 1 or ".." in candidate.parts:
|
|
98
|
+
raise ValueError(
|
|
99
|
+
f"{flag} 只接受运行目录内的文件名(不含路径):{name}\n"
|
|
100
|
+
f"产物统一放在运行目录:{run_dir}"
|
|
101
|
+
)
|
|
102
|
+
target = (run_dir / candidate.name).resolve()
|
|
103
|
+
_reject_skill_path(target, flag)
|
|
104
|
+
if target.exists():
|
|
105
|
+
raise ValueError(f"{flag} 文件已存在,不覆盖已有产物:{target}")
|
|
106
|
+
return target
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def resolve_input(value: str) -> Path:
|
|
110
|
+
"""输入路径:相对路径按当前工作目录解析;必须是已存在文件(由调用方判断存在性)。"""
|
|
111
|
+
return _resolve(value)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def resolve_run_input(value: str, run_dir_path: str = "") -> Path:
|
|
115
|
+
"""运行目录内的输入:传了 run 目录时,裸文件名优先按 run 目录解析,其次 cwd。"""
|
|
116
|
+
raw = Path(str(value or "")).expanduser()
|
|
117
|
+
if run_dir_path and not raw.is_absolute() and "/" not in str(value):
|
|
118
|
+
candidate = _resolve(str(Path(run_dir_path) / raw))
|
|
119
|
+
if candidate.is_file():
|
|
120
|
+
return candidate
|
|
121
|
+
return resolve_input(value)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def resolve_output_path(value: str) -> Path:
|
|
125
|
+
"""显式输出路径(不带 --run 时用):拒绝 Skill 安装目录内。"""
|
|
126
|
+
path = _resolve(value)
|
|
127
|
+
_reject_skill_path(path, "--output")
|
|
128
|
+
return path
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
_SAFE_NAME = re.compile(r"^[A-Za-z0-9_.\-一-鿿]+$")
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def is_bare_filename(value: str) -> bool:
|
|
135
|
+
raw = str(value or "").strip()
|
|
136
|
+
return bool(raw) and bool(_SAFE_NAME.match(raw)) and "/" not in raw and "\\" not in raw
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def resolve_write_target(output: str, run_dir_path: str = "", *, flag: str = "--output") -> Path:
|
|
140
|
+
"""输出目标统一解析:
|
|
141
|
+
- 传了运行目录(--out/--run):output 必须是裸文件名,落在运行目录内且不覆盖;
|
|
142
|
+
- 未传运行目录:output 必须是显式路径,拒绝 Skill 安装目录内。
|
|
143
|
+
"""
|
|
144
|
+
if run_dir_path:
|
|
145
|
+
run = ensure_run_dir(run_dir_path, "--out")
|
|
146
|
+
return out_file(run, output or "", flag)
|
|
147
|
+
if not str(output or "").strip():
|
|
148
|
+
raise ValueError(f"未提供 {flag}:请传 --out 运行目录 + 文件名,或显式输出路径")
|
|
149
|
+
return resolve_output_path(output)
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""材料画像:把税务检索结果转成带地域、来源性质、文件类型、抓取状态的 source cards。
|
|
3
|
+
|
|
4
|
+
输入:tax_search.py / merge_search_results.py 的 JSON,或含"检索文章"数组的对象。
|
|
5
|
+
输出:tax_source_cards.json
|
|
6
|
+
|
|
7
|
+
设计目的:让"河北的口径被当成北京的口径""新闻报道被当成政策原文"这类问题
|
|
8
|
+
在材料层就暴露,而不是等模型写进答案后再靠人发现。
|
|
9
|
+
|
|
10
|
+
来源标签语义(2026-11-10 与深知系列产品口径对齐):
|
|
11
|
+
- `source_grade`:官方库 / 政府网站 / 官方媒体 / 次级媒体 / 未知。
|
|
12
|
+
"官方库"=深知库内材料;外部材料按来源性质取值。
|
|
13
|
+
- `source_nature`:政府网站 / 官方媒体 / 次级媒体 / 未知。
|
|
14
|
+
`非官方来源=True` 只表示"不是深知库内材料",不等于网站本身不官方;
|
|
15
|
+
政府网站、官方媒体要如实区分,无法判断写"未知",不要合并成"次级媒体/未知"。
|
|
16
|
+
- `source_channel`:深知库内 / 外部联网。
|
|
17
|
+
|
|
18
|
+
用法:
|
|
19
|
+
python3 scripts/source_cards.py \
|
|
20
|
+
--input tax_<任务>_merged.json \
|
|
21
|
+
--profile tax_question_profile.json \
|
|
22
|
+
--output tax_source_cards.json
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
import argparse
|
|
28
|
+
import json
|
|
29
|
+
import re
|
|
30
|
+
import sys
|
|
31
|
+
from typing import Any, Dict, List
|
|
32
|
+
from urllib.parse import urlparse
|
|
33
|
+
|
|
34
|
+
from question_profile import CITY_PROVINCE, PROVINCES, PROVINCE_SHORT
|
|
35
|
+
import run_dir
|
|
36
|
+
|
|
37
|
+
PROVINCE_DOMAIN_PREFIX = {
|
|
38
|
+
"bj": "北京市", "tj": "天津市", "he": "河北省", "sx": "山西省",
|
|
39
|
+
"nm": "内蒙古自治区", "ln": "辽宁省", "jl": "吉林省", "hl": "黑龙江省",
|
|
40
|
+
"sh": "上海市", "js": "江苏省", "zj": "浙江省", "ah": "安徽省",
|
|
41
|
+
"fj": "福建省", "jx": "江西省", "sd": "山东省", "ha": "河南省",
|
|
42
|
+
"hb": "湖北省", "hn": "湖南省", "gd": "广东省", "gx": "广西壮族自治区",
|
|
43
|
+
"hi": "海南省", "cq": "重庆市", "sc": "四川省", "gz": "贵州省",
|
|
44
|
+
"yn": "云南省", "xz": "西藏自治区", "sn": "陕西省", "gs": "甘肃省",
|
|
45
|
+
"qh": "青海省", "nx": "宁夏回族自治区", "xj": "新疆维吾尔自治区",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
NATIONAL_TERMS = (
|
|
49
|
+
"全国", "中华人民共和国", "国务院", "全国人民代表大会", "全国人大常委会",
|
|
50
|
+
"国家税务总局", "财政部", "海关总署", "人力资源和社会保障部", "国家医保局",
|
|
51
|
+
"国家发展改革委", "工业和信息化部", "住房和城乡建设部", "商务部",
|
|
52
|
+
"国家市场监督管理总局", "中共中央", "最高人民法院", "最高人民检察院",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
GOV_TERMS = (
|
|
56
|
+
"国务院", "人民政府", "税务局", "税务分局", "财政厅", "财政局", "财政部",
|
|
57
|
+
"人力资源和社会保障局", "人力资源和社会保障厅", "人社局", "医保局",
|
|
58
|
+
"海关", "发展和改革委员会", "工信厅", "工业和信息化厅", "住房和城乡建设厅",
|
|
59
|
+
"市场监督管理局", "国家税务总局",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
OFFICIAL_MEDIA_TERMS = (
|
|
63
|
+
"中国政府网", "新华社", "新华网", "人民日报", "人民网", "央视", "中央电视台",
|
|
64
|
+
"中国税务报", "中国税务网", "经济日报", "光明日报", "央广网", "中国新闻网",
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
SECONDARY_TERMS = (
|
|
68
|
+
"新闻", "日报", "晚报", "时报", "商报", "财经", "资讯", "网", "搜狐", "新浪",
|
|
69
|
+
"网易", "腾讯", "百家号", "头条", "知乎", "微博", "公众号", "自媒体",
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _first(item: Dict[str, Any], *keys: str) -> str:
|
|
74
|
+
for key in keys:
|
|
75
|
+
value = item.get(key)
|
|
76
|
+
if isinstance(value, str) and value.strip():
|
|
77
|
+
return value.strip()
|
|
78
|
+
return ""
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _articles(payload: Any) -> List[Dict[str, Any]]:
|
|
82
|
+
if isinstance(payload, list):
|
|
83
|
+
return [x for x in payload if isinstance(x, dict)]
|
|
84
|
+
if not isinstance(payload, dict):
|
|
85
|
+
return []
|
|
86
|
+
content = payload.get("content") if isinstance(payload.get("content"), dict) else payload
|
|
87
|
+
data = content.get("data") if isinstance(content.get("data"), dict) else content
|
|
88
|
+
if isinstance(data, dict):
|
|
89
|
+
arts = data.get("检索文章")
|
|
90
|
+
if isinstance(arts, list):
|
|
91
|
+
return [x for x in arts if isinstance(x, dict)]
|
|
92
|
+
arts = payload.get("检索文章")
|
|
93
|
+
return [x for x in arts if isinstance(x, dict)] if isinstance(arts, list) else []
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _host(url: str) -> str:
|
|
97
|
+
try:
|
|
98
|
+
return (urlparse(url).hostname or "").lower() if url else ""
|
|
99
|
+
except Exception: # noqa: BLE001
|
|
100
|
+
return ""
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _has_local_marker(text: str) -> str:
|
|
104
|
+
province = next((p for p in PROVINCES if p in text), "")
|
|
105
|
+
if province:
|
|
106
|
+
return province
|
|
107
|
+
for short in sorted(PROVINCE_SHORT, key=len, reverse=True):
|
|
108
|
+
if short and short in text:
|
|
109
|
+
return PROVINCE_SHORT[short]
|
|
110
|
+
return ""
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _infer_jurisdiction(item: Dict[str, Any]) -> str:
|
|
114
|
+
area = _first(item, "办理地域", "地域", "area")
|
|
115
|
+
# 合并产物常给每篇带一个泛化的"办理地域=中国",不能据此把地方文件标成全国。
|
|
116
|
+
if area in ("中国", "全国"):
|
|
117
|
+
area = ""
|
|
118
|
+
if area:
|
|
119
|
+
return area
|
|
120
|
+
|
|
121
|
+
# 只从标题/机构/数据源判断,不扫描全文:政策全文常提到多个省份,
|
|
122
|
+
# 用全文匹配会把中央文件误标成它正文里提到的某个省。
|
|
123
|
+
title = _first(item, "文章标题", "标题")
|
|
124
|
+
issuer = _first(item, "发布或实施机构", "发布机关")
|
|
125
|
+
source = _first(item, "数据源")
|
|
126
|
+
url = _first(item, "源网址", "url", "原文链接")
|
|
127
|
+
meta = " ".join([title, issuer, source])
|
|
128
|
+
|
|
129
|
+
# 地方税务机关的机构名本身带省市(国家税务总局北京市税务局),先认地方。
|
|
130
|
+
issuer_local = _has_local_marker(issuer)
|
|
131
|
+
if issuer_local:
|
|
132
|
+
return issuer_local
|
|
133
|
+
# 发布机关是中央部委/总局(财政部、国家税务总局…)即全国口径:
|
|
134
|
+
# 中央文件被地方门户/镜像站转载时,不能因为数据源在某省就判成地方文件。
|
|
135
|
+
if any(term in issuer for term in NATIONAL_TERMS):
|
|
136
|
+
return "全国"
|
|
137
|
+
title_local = _has_local_marker(title)
|
|
138
|
+
central_title = any(term in title for term in NATIONAL_TERMS)
|
|
139
|
+
# 地方税务局/财政厅的标题带省名(即使含"国家税务总局"前缀)先认地方;
|
|
140
|
+
# 中央机关文件标题提到某省(如"国务院关于河北省……")仍归全国。
|
|
141
|
+
local_bureau_title = re.search(
|
|
142
|
+
r"(省|市|自治区|区|县)[^ ]{0,8}(税务局|财政厅|财政局|人民政府|人社局)", title
|
|
143
|
+
)
|
|
144
|
+
if title_local and (local_bureau_title or not central_title):
|
|
145
|
+
return title_local
|
|
146
|
+
if central_title:
|
|
147
|
+
return "全国"
|
|
148
|
+
|
|
149
|
+
# 数据源本身是地方税务机关/政府网站时补认地方;中央文件被地方门户转载不适用
|
|
150
|
+
# (上面 central_title 已归全国)。
|
|
151
|
+
source_local = _has_local_marker(source)
|
|
152
|
+
if source_local and re.search(r"税务局|财政厅|财政局|人民政府|人社局", source):
|
|
153
|
+
return source_local
|
|
154
|
+
|
|
155
|
+
for city in sorted(CITY_PROVINCE, key=len, reverse=True):
|
|
156
|
+
if city in meta or city in url:
|
|
157
|
+
return CITY_PROVINCE[city]
|
|
158
|
+
if any(term in meta for term in NATIONAL_TERMS):
|
|
159
|
+
return "全国"
|
|
160
|
+
|
|
161
|
+
host = _host(url)
|
|
162
|
+
labels = host.split(".") if host else []
|
|
163
|
+
label = labels[0] if labels else ""
|
|
164
|
+
if label in ("www", "m") and len(labels) > 1:
|
|
165
|
+
label = labels[1]
|
|
166
|
+
for city in sorted(CITY_PROVINCE, key=len, reverse=True):
|
|
167
|
+
if label and label.startswith(city.lower()):
|
|
168
|
+
return CITY_PROVINCE[city]
|
|
169
|
+
if len(label) >= 2 and label[:2] in PROVINCE_DOMAIN_PREFIX:
|
|
170
|
+
return PROVINCE_DOMAIN_PREFIX[label[:2]]
|
|
171
|
+
return ""
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def _infer_nature(item: Dict[str, Any], unofficial: bool) -> str:
|
|
175
|
+
explicit = _first(item, "来源性质", "source_nature")
|
|
176
|
+
if explicit in ("政府网站", "官方媒体", "次级媒体", "未知"):
|
|
177
|
+
return explicit
|
|
178
|
+
if not unofficial:
|
|
179
|
+
issuer = _first(item, "发布或实施机构", "发布机关")
|
|
180
|
+
return "政府网站" if any(term in issuer for term in GOV_TERMS) else "未知"
|
|
181
|
+
issuer = _first(item, "发布或实施机构", "发布机关", "数据源")
|
|
182
|
+
url = _first(item, "源网址", "url", "原文链接")
|
|
183
|
+
host = _host(url)
|
|
184
|
+
if host.endswith(".gov.cn") or any(term in issuer for term in GOV_TERMS):
|
|
185
|
+
return "政府网站"
|
|
186
|
+
if any(term in issuer for term in OFFICIAL_MEDIA_TERMS) or host.endswith("gov.cn"):
|
|
187
|
+
return "官方媒体"
|
|
188
|
+
if any(term in issuer for term in SECONDARY_TERMS) or any(
|
|
189
|
+
term in host for term in ("news", "sina", "sohu", "163.com", "qq.com", "baidu.com")
|
|
190
|
+
):
|
|
191
|
+
return "次级媒体"
|
|
192
|
+
return "未知"
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _source_grade(nature: str, unofficial: bool, explicit: bool) -> str:
|
|
196
|
+
# 显式来源性质优先:上游已写“次级媒体/未知”时,即使漏标非官方来源,
|
|
197
|
+
# 也不能洗成“官方库”。库内材料无显式性质时才记“官方库”。
|
|
198
|
+
if explicit:
|
|
199
|
+
return "官方库" if (not unofficial and nature in ("政府网站", "官方媒体")) else nature
|
|
200
|
+
return "官方库" if not unofficial else (nature or "未知")
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def _is_official(nature: str) -> bool:
|
|
204
|
+
return nature in ("政府网站", "官方媒体")
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def _doc_type(item: Dict[str, Any]) -> str:
|
|
208
|
+
title = _first(item, "文章标题", "标题")
|
|
209
|
+
doc_no = _first(item, "发文字号", "文号")
|
|
210
|
+
issuer = _first(item, "发布或实施机构", "发布机关")
|
|
211
|
+
issuer_full = _first(item, "发布或实施机构", "发布机关", "数据源")
|
|
212
|
+
text = " ".join([title, doc_no, issuer_full])
|
|
213
|
+
if re.search(r"GB(?:/T)?\s*\d", text):
|
|
214
|
+
return "国家标准"
|
|
215
|
+
# "问答/解读"看标题和发布机关,不看数据源:政策原文可能被门户的问答栏目转载。
|
|
216
|
+
if re.search(r"解读|问答|答记者问|一图读懂|图解", " ".join([title, issuer])):
|
|
217
|
+
return "政策解读"
|
|
218
|
+
if re.search(r"新闻|报道|记者", title) or re.search(
|
|
219
|
+
r"新华社|人民日报|央视|中国税务报|日报|晚报|新闻网", issuer
|
|
220
|
+
):
|
|
221
|
+
return "新闻报道"
|
|
222
|
+
if re.search(r"《[^》]*法》", title) or title.endswith("法"):
|
|
223
|
+
return "法律"
|
|
224
|
+
if "条例" in text:
|
|
225
|
+
return "行政法规"
|
|
226
|
+
if re.search(r"令第|部令|总局令|部门规章", text):
|
|
227
|
+
return "部门规章"
|
|
228
|
+
local_issuer = bool(_has_local_marker(issuer_full))
|
|
229
|
+
if re.search(r"公告|通知|办法|规定|意见|批复|实施细则", title):
|
|
230
|
+
return "地方政策" if local_issuer else "规范性文件"
|
|
231
|
+
if "公告" in text or "通知" in text:
|
|
232
|
+
return "地方政策" if local_issuer else "规范性文件"
|
|
233
|
+
if local_issuer:
|
|
234
|
+
return "地方政策"
|
|
235
|
+
return "其他"
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def _channel(item: Dict[str, Any], unofficial: bool) -> str:
|
|
239
|
+
raw = _first(item, "检索通道", "channel")
|
|
240
|
+
if unofficial or "联网" in raw or "WebSearch" in raw:
|
|
241
|
+
return "外部联网"
|
|
242
|
+
return "深知库内"
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def _spans(item: Dict[str, Any]) -> List[str]:
|
|
246
|
+
spans: List[str] = []
|
|
247
|
+
for para in item.get("段落") or []:
|
|
248
|
+
if isinstance(para, dict):
|
|
249
|
+
text = str(para.get("内容") or para.get("text") or "").strip()
|
|
250
|
+
else:
|
|
251
|
+
text = str(para or "").strip()
|
|
252
|
+
if text:
|
|
253
|
+
spans.append(text)
|
|
254
|
+
return spans
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def _tax_types(item: Dict[str, Any], title: str) -> List[str]:
|
|
258
|
+
tags = item.get("文件标签") or []
|
|
259
|
+
if not isinstance(tags, list):
|
|
260
|
+
tags = [tags]
|
|
261
|
+
found = [str(x).split("/")[-1] for x in tags if str(x).strip()]
|
|
262
|
+
probes = {
|
|
263
|
+
"增值税": ("增值税",), "企业所得税": ("企业所得税",), "个人所得税": ("个人所得税", "个税"),
|
|
264
|
+
"消费税": ("消费税",), "房产税": ("房产税",), "车辆购置税": ("车辆购置税", "车购税"),
|
|
265
|
+
"印花税": ("印花税",), "契税": ("契税",), "资源税": ("资源税",),
|
|
266
|
+
"土地增值税": ("土地增值税",), "关税": ("关税",), "烟叶税": ("烟叶税",),
|
|
267
|
+
"环境保护税": ("环境保护税", "环保税"), "社会保险费": ("社会保险", "社保", "养老保险"),
|
|
268
|
+
}
|
|
269
|
+
for name, terms in probes.items():
|
|
270
|
+
if any(term in title for term in terms) and name not in found:
|
|
271
|
+
found.append(name)
|
|
272
|
+
return [x for x in found if x]
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def build_cards(payload: Any, question_jurisdiction: str = "") -> Dict[str, Any]:
|
|
276
|
+
cards: List[Dict[str, Any]] = []
|
|
277
|
+
warnings: List[str] = []
|
|
278
|
+
for idx, item in enumerate(_articles(payload), start=1):
|
|
279
|
+
spans = _spans(item)
|
|
280
|
+
unofficial = bool(item.get("非官方来源"))
|
|
281
|
+
explicit_nature = _first(item, "来源性质", "source_nature")
|
|
282
|
+
explicit = explicit_nature in ("政府网站", "官方媒体", "次级媒体", "未知")
|
|
283
|
+
nature = _infer_nature(item, unofficial)
|
|
284
|
+
if explicit:
|
|
285
|
+
nature = explicit_nature
|
|
286
|
+
jurisdiction = _infer_jurisdiction(item)
|
|
287
|
+
title = _first(item, "文章标题", "标题")
|
|
288
|
+
official = _is_official(nature) if (unofficial or explicit) else True
|
|
289
|
+
api_authority = _first(item, "数据权威性", "authority")
|
|
290
|
+
data_authority = "非权威" if unofficial else api_authority
|
|
291
|
+
sid = str(item.get("文章Id") or f"s{idx}")
|
|
292
|
+
if unofficial and api_authority == "权威":
|
|
293
|
+
warnings.append(
|
|
294
|
+
f"来源 {sid} 是非官方来源但接口标了数据权威性=权威,已按非权威处理"
|
|
295
|
+
)
|
|
296
|
+
if unofficial and not explicit and nature == "未知":
|
|
297
|
+
warnings.append(f"来源 {sid} 无法判定来源性质,已标“未知”")
|
|
298
|
+
cards.append({
|
|
299
|
+
"id": str(item.get("文章Id") or f"s{idx}"),
|
|
300
|
+
"article_no": item.get("编号"),
|
|
301
|
+
"title": title,
|
|
302
|
+
"issuer": _first(item, "发布或实施机构", "发布机关"),
|
|
303
|
+
"jurisdiction": jurisdiction,
|
|
304
|
+
"jurisdiction_status": "known" if jurisdiction else "unknown",
|
|
305
|
+
"doc_type": _doc_type(item),
|
|
306
|
+
"source_grade": _source_grade(nature, unofficial, explicit),
|
|
307
|
+
"source_nature": nature,
|
|
308
|
+
"source_nature_status": "explicit" if explicit else "inferred",
|
|
309
|
+
"source_channel": _channel(item, unofficial),
|
|
310
|
+
"official": official,
|
|
311
|
+
"library_material": not unofficial,
|
|
312
|
+
"data_authority": data_authority,
|
|
313
|
+
"published_at": _first(item, "发布日期", "date"),
|
|
314
|
+
"effective_at": _first(item, "生效日期", "effectiveDate"),
|
|
315
|
+
"url": _first(item, "源网址", "url", "原文链接"),
|
|
316
|
+
"doc_number": _first(item, "发文字号", "文号"),
|
|
317
|
+
"tax_types": _tax_types(item, title),
|
|
318
|
+
"channel": _channel(item, unofficial),
|
|
319
|
+
"fetch_status": "ok" if spans else "failed",
|
|
320
|
+
"spans": spans,
|
|
321
|
+
})
|
|
322
|
+
return {
|
|
323
|
+
"question_jurisdiction": question_jurisdiction,
|
|
324
|
+
"sources": cards,
|
|
325
|
+
"warnings": warnings,
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def main() -> int:
|
|
330
|
+
parser = argparse.ArgumentParser(description="生成税务材料画像 source cards")
|
|
331
|
+
parser.add_argument("--input", required=True, help="检索结果 JSON")
|
|
332
|
+
parser.add_argument("--profile", help="问题画像 JSON(读取 jurisdiction / tax_types)")
|
|
333
|
+
parser.add_argument("--out", help="运行目录(会话工作区);与 --output 文件名一起用")
|
|
334
|
+
parser.add_argument("--output", default="tax_source_cards.json",
|
|
335
|
+
help="输出文件名(配合 --out)或显式输出路径(不得指向 Skill 安装目录)")
|
|
336
|
+
args = parser.parse_args()
|
|
337
|
+
|
|
338
|
+
try:
|
|
339
|
+
payload = json.loads(
|
|
340
|
+
run_dir.resolve_run_input(args.input, args.out).read_text(encoding="utf-8")
|
|
341
|
+
)
|
|
342
|
+
except (OSError, json.JSONDecodeError, ValueError) as exc:
|
|
343
|
+
parser.error(f"输入不可读:{exc}")
|
|
344
|
+
question_jurisdiction = ""
|
|
345
|
+
if args.profile:
|
|
346
|
+
try:
|
|
347
|
+
profile = json.loads(
|
|
348
|
+
run_dir.resolve_run_input(args.profile, args.out).read_text(encoding="utf-8")
|
|
349
|
+
)
|
|
350
|
+
question_jurisdiction = str(profile.get("jurisdiction") or "")
|
|
351
|
+
except (OSError, json.JSONDecodeError, ValueError) as exc:
|
|
352
|
+
parser.error(f"profile 不可读:{exc}")
|
|
353
|
+
|
|
354
|
+
try:
|
|
355
|
+
out = run_dir.resolve_write_target(args.output, args.out)
|
|
356
|
+
except ValueError as exc:
|
|
357
|
+
parser.error(str(exc))
|
|
358
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
359
|
+
result = build_cards(payload, question_jurisdiction)
|
|
360
|
+
out.write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
361
|
+
for warning in result.get("warnings") or []:
|
|
362
|
+
print(f"材料画像告警:{warning}", file=sys.stderr)
|
|
363
|
+
print(json.dumps({
|
|
364
|
+
"output": str(out),
|
|
365
|
+
"sources": len(result["sources"]),
|
|
366
|
+
"warnings": len(result.get("warnings") or []),
|
|
367
|
+
}, ensure_ascii=False, indent=2))
|
|
368
|
+
return 0
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
if __name__ == "__main__":
|
|
372
|
+
raise SystemExit(main())
|