yuandian-law-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese元典法条与案例检索
Yuandian Law Article and Case Retrieval
通过元典 API 检索中国法律法规条文和案例,支持法条语义/关键词/详情检索和案例关键词/向量语义检索共 5 种模式。
Retrieve provisions of Chinese laws and regulations and cases through Yuandian API, supporting a total of 5 modes: law article semantic/keyword/detailed retrieval and case keyword/vector semantic retrieval.
前置要求(每次调用前自动检测)
Prerequisites (automatically detected before each call)
每次使用本技能前,必须先执行以下检测流程,确认 API Key 已就绪:
Before using this skill each time, you must perform the following detection process first to confirm that the API Key is ready:
检测步骤
Detection Steps
- 检测 文件:检查
.env是否存在scripts/.env - 检测 API Key:读取文件中 的值,确认非空且不是占位符
YD_API_KEYyour-api-key-here - 若检测失败,向用户提示以下引导信息并终止:
⚠️ 元典 API Key 未配置。请按以下步骤获取并配置:
1. 注册/登录:访问 https://passport.legalmind.cn/ ,使用手机号注册
2. 创建 API Key:登录后访问 https://passport.legalmind.cn/apiKey/manage ,点击「创建 Key」
3. 配置密钥:将 Key 填入以下文件
scripts/.env
─────────────
YD_API_KEY=sk-你的密钥
─────────────
API 覆盖范围:法条检索(语义/关键词/详情)+ 案例检索(关键词/向量语义),共 5 个端点,共用同一个 Key。
配置完成后重新发起检索即可。- 若检测通过,继续执行用户请求的检索命令
- Detect file: Check if
.envexistsscripts/.env - Detect API Key: Read the value of in the file, confirm it is not empty and not the placeholder
YD_API_KEYyour-api-key-here - If the detection fails, prompt the user with the following guidance information and terminate:
⚠️ 元典 API Key 未配置。请按以下步骤获取并配置:
1. 注册/登录:访问 https://passport.legalmind.cn/ ,使用手机号注册
2. 创建 API Key:登录后访问 https://passport.legalmind.cn/apiKey/manage ,点击「创建 Key」
3. 配置密钥:将 Key 填入以下文件
scripts/.env
─────────────
YD_API_KEY=sk-你的密钥
─────────────
API 覆盖范围:法条检索(语义/关键词/详情)+ 案例检索(关键词/向量语义),共 5 个端点,共用同一个 Key。
配置完成后重新发起检索即可。- If the detection passes, continue to execute the retrieval command requested by the user
检测命令
Detection Command
bash
undefinedbash
undefined检测 .env 文件和 API Key
检测 .env 文件和 API Key
if [ -f "scripts/.env" ]; then
KEY=$(grep '^YD_API_KEY=' scripts/.env | cut -d'=' -f2)
if [ -n "$KEY" ] && [ "$KEY" != "your-api-key-here" ]; then
echo "API Key 已就绪"
else
echo "API Key 未配置"
fi
else
echo ".env 文件不存在"
fi
undefinedif [ -f "scripts/.env" ]; then
KEY=$(grep '^YD_API_KEY=' scripts/.env | cut -d'=' -f2)
if [ -n "$KEY" ] && [ "$KEY" != "your-api-key-here" ]; then
echo "API Key 已就绪"
else
echo "API Key 未配置"
fi
else
echo ".env 文件不存在"
fi
undefined五种检索模式
Five Retrieval Modes
1. 法条语义检索(search)
1. Law Article Semantic Retrieval (search)
用自然语言提问,找到最相关的法条。
bash
python3 scripts/yd_search.py search "正当防卫的限度" --sxx 现行有效Ask questions in natural language to find the most relevant law articles.
bash
python3 scripts/yd_search.py search "正当防卫的限度" --sxx 现行有效2. 法条关键词检索(keyword)
2. Law Article Keyword Retrieval (keyword)
用精确关键词检索法条,支持日期范围和效力级别筛选。
bash
python3 scripts/yd_search.py keyword "人工智能 监管" \
--effect1 法律 --sxx 现行有效 \
--fbrq-start 2022-01-01 --fbrq-end 2026-03-01Retrieve law articles with precise keywords, supporting date range and effectiveness level filtering.
bash
python3 scripts/yd_search.py keyword "人工智能 监管" \
--effect1 法律 --sxx 现行有效 \
--fbrq-start 2022-01-01 --fbrq-end 2026-03-013. 法条详情检索(detail)
3. Law Article Detail Retrieval (detail)
按法规名称 + 条号精确获取某一条法条全文。
bash
python3 scripts/yd_search.py detail "民法典" --ft-name "第十五条"Accurately obtain the full text of a specific law article by regulation name + article number.
bash
python3 scripts/yd_search.py detail "民法典" --ft-name "第十五条"4. 案例关键词检索(case)
4. Case Keyword Retrieval (case)
用关键词检索案例,支持案由、法院、省份等多维过滤。
bash
python3 scripts/yd_search.py case "买卖合同纠纷" --province 广西 --authority-onlyRetrieve cases with keywords, supporting multi-dimensional filtering such as cause of action, court, province, etc.
bash
python3 scripts/yd_search.py case "买卖合同纠纷" --province 广西 --authority-only5. 案例语义检索(case-semantic)
5. Case Semantic Retrieval (case-semantic)
用自然语言描述查找相似案例。
bash
python3 scripts/yd_search.py case-semantic "正当防卫的限度" --jarq-start 2020-01-01Find similar cases by description in natural language.
bash
python3 scripts/yd_search.py case-semantic "正当防卫的限度" --jarq-start 2020-01-01通用参数说明
General Parameter Description
法条检索通用筛选
General Filter for Law Article Retrieval
| 参数 | 说明 | 可选值 |
|---|---|---|
| 效力级别(可多次指定) | 宪法、法律、司法解释、行政法规、部门规章、地方性法规 等 |
| 时效性(可多次指定) | 现行有效、失效、已被修改、部分失效、尚未生效 |
| Parameter | Description | Optional Values |
|---|---|---|
| Effectiveness level (can be specified multiple times) | Constitution, Law, Judicial Interpretation, Administrative Regulation, Departmental Rule, Local Regulation, etc. |
| Timeliness (can be specified multiple times) | Currently Valid, Invalid, Amended, Partially Invalid, Not Yet Effective |
案例检索通用筛选
General Filter for Case Retrieval
| 参数 | 说明 |
|---|---|
| 仅检索权威/典型案例 |
| 省份筛选 |
| 结案日期范围 |
完整参数说明见 references/api-spec.md。
| Parameter | Description |
|---|---|
| Only retrieve authoritative/typical cases |
| Province filter |
| Case closing date range |
For complete parameter description, see references/api-spec.md.
输出格式
Output Format
脚本输出 Markdown 格式,包含法条全文、法规名称、发布机关、时效性等元信息,以及原文链接。可直接用于法律文书引用或 AI 分析。
The script outputs in Markdown format, including meta information such as full text of law articles, regulation name, issuing authority, timeliness, and original link. It can be directly used for legal document citation or AI analysis.
调试
Debugging
使用 子命令查看原始 JSON 响应:
rawbash
python3 scripts/yd_search.py raw /search "正当防卫" --extra '{"sxx":["现行有效"]}'Use the subcommand to view the original JSON response:
rawbash
python3 scripts/yd_search.py raw /search "正当防卫" --extra '{"sxx":["现行有效"]}'