angineer-sop-core
SOP(标准作业流程)编写库:加载 / 解析 / 校验 / 生成。不含执行——
SOP / Step 契约与 sop_execute 执行器在 angineer-core;
本库不连数据库、不做检索,图谱读取由消费方按 GraphReader 协议注入。
| 能力 | 入口 | 依赖 |
|---|---|---|
| 加载(json/、raw/ → SOP,index.json 生成,状态过滤) | SopLoader |
无(纯本地目录) |
| 校验(步骤图 / 变量闭包 / 表达式 / 工具名) | validate_sop_data、validate_sop |
无 |
| 解析(步骤描述 → 工具/inputs/outputs 绑定) | SopParser |
LLM 可选(失败回退规则) |
| 生成(图谱框架路径 → 完整 SOP) | SopPathGenerator |
图谱端口 + LLM |
安装
pip install angineer-sop-core
加载
from sop_core import SopLoader
loader = SopLoader("<sop_base_dir>") # 目录内放 json/(可选 raw/、index.json)
sops = loader.load_all() # 缺省只取 published;index.json 缺失时自动生成
print([s.name_zh for s in sops])
- 目录布局:
json/<id>.json为唯一真相源;raw/*.md仅作兼容数据源(json 未注册时才收录);index.json是生成物,SopLoader会按文件信号(index.json mtime + json/、raw/ 快照)自动失效重建。 - 缓存:进程内按文件信号失效,
ANGINEER_SOP_CACHE_TTL只作兜底(默认 300 秒,0停用缓存)。 - 状态:JSON 里无
status键即视为published;draft/disabled需显式声明,load_all(include_status=("published", "draft"))可放宽。
校验
from sop_core.sop_validator import validate_sop_data
problems = validate_sop_data({"name_zh": "...", "steps": [...]})
# 空列表 = 通过;否则是逐条问题描述(步骤图环/悬空引用、变量闭包不可达、
# calculator 缺 expression、工具名不认识等)
生成
from sop_core import SopPathGenerator
from sop_core.graph_port import GraphReader # 消费方实现的只读图谱端口(8 个方法)
gen = SopPathGenerator(store=my_graph_reader, config_name=None) # config_name 交给 ai-inference 默认配置
sop = gen.generate_sop_from_steps("框架名", ["步骤 1", "步骤 2"],
source_section="出处", library_id="...", doc_id="...")
- LLM 优先、失败回退确定性骨架;LLM 调用经
angineer-ai-inference的LLM_CONFIGS。 graph_port只定协议不给实现:本地直连(GraphStore)或 HTTP 适配都行, 实体层字符串常量(LAYER_CONCEPT/LAYER_CONDITION/LAYER_ACTION)与文档解析侧对齐。- 落盘:
SopLoader.save_generated_sop(...)显式写json/; 生成器内部的「参考 SOP 读取 / 批量落盘」目录取$DATA_DIR(缺省<当前目录>/data/platform/sops), 独立使用时请显式设置该环境变量。
测试
pip install -e . pytest
pytest tests -q
相关仓库
| 包 | 职责 |
|---|---|
| angineer-core | SOP 契约(SOP/Step)+ sop_execute 执行器 + 问答编排 |
| angineer-ai-inference | LLM 客户端(多端点路由 / 重试 / 熔断) |
| angineer-docs-core | 文档解析入库(图谱实体由 GraphReader 侧提供) |
License
MIT
Metadata
Release files for angineer-sop-core 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| angineer_sop_core-0.1.0.tar.gz | 27.4 kB | With provenance | Details for angineer_sop_core-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| angineer_sop_core-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for angineer_sop_core-0.1.0-py3-none-any.whl |
Total release size: 56.5 kB
Release files / angineer_sop_core-0.1.0.tar.gz
| Download URL | angineer_sop_core-0.1.0.tar.gz |
|---|---|
| Size | 27.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e7c827124e052df345800bd0a6e18f1f5bfb9b9781946f6edfffd369eb3ab86
|
|
BLAKE2b-256 checksum How to use checksums |
84f554b6651161040d437625e8889ae45e0bd89c456f3938f40b1d8a99e76a0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / angineer_sop_core-0.1.0-py3-none-any.whl
| Download URL | angineer_sop_core-0.1.0-py3-none-any.whl |
|---|---|
| Size | 29.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
551f9830c2df8f54decbab8294aee448d8ee0e06a4c652f409dcefb1985ad266
|
|
BLAKE2b-256 checksum How to use checksums |
891f768b56947fac06de7e7660085d5ad391b20454d93d19a070c21868d898c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logSecurity for angineer-sop-core 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for angineer_sop_core-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.