Rag skills ali
Use when needing to search or retrieve information from Alibaba Cloud Bailian knowledge base, when user asks about knowledge base queries, document retrieval, semantic search, or any Bailian-powered information lookupFrom its SKILL.md
npx -y skills add konglong87/rag_skills_aliAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.9 KB, ~2.0k tokens by cl100k_base, as published. Nobody here has run it
Bailian Knowledge Query
阿里云百炼知识库检索工具。编译好的二进制,零依赖运行,返回结构化 JSON。
Security Warning
config.json 包含阿里云 AK/SK 密钥。
Prerequisites
config.json 已配置(skill 目录下):
{
"alibaba_cloud_access_key_id": "your_key",
"alibaba_cloud_access_key_secret": "your_secret",
"workspace_id": "your_workspace",
"knowledge_index_id": "your_index",
"endpoint": "bailian.cn-beijing.aliyuncs.com"
}
Usage
根据操作系统选择二进制:
| OS | Binary |
|---|---|
| macOS | bailian-query-mac |
| Linux amd64 | bailian-query-linux |
| Windows amd64 | bailian-query-win64.exe |
SKILL_DIR=$(dirname "$0")
# macOS
$SKILL_DIR/bin/bailian-query-mac -config $SKILL_DIR/config.json "初诊患者怎么随访"
# Linux
$SKILL_DIR/bin/bailian-query-linux -config $SKILL_DIR/config.json "初诊患者怎么随访"
Parameters
| 参数 | 说明 | 必填 |
|---|---|---|
-config | config.json 路径 | 是(默认 config.json) |
<query> | 检索查询语句 | 是 |
[workspace_id] | 覆盖配置中的 workspace_id | 否 |
[index_id] | 覆盖配置中的 knowledge_index_id | 否 |
Examples
# 基本查询
bailian-query-mac -config config.json "初诊患者怎么随访"
# 覆盖 workspace 和 index
bailian-query-mac -config config.json "吸入过敏原" custom_workspace custom_index
Output Structure
返回 JSON,核心字段:
{
"Code": "Success", // 状态码: Success / 错误码
"Data": {
"Nodes": [ // 匹配文档片段列表,按相关性降序
{
"Score": 0.854, // 相关性评分 (0-1),>0.7 为高相关
"Text": "...", // 匹配的文档内容片段
"Metadata": {
"doc_name": "...", // 来源文档名
"title": "...", // 文档层级标题
"hier_title": "...", // 层级路径 (如 "哮喘照护 > 初诊 > 随访")
"page_number": [1], // 来源页码
"doc_url": "..." // 文档下载链接 (带过期时间)
}
}
]
},
"RequestId": "...",
"Success": true
}
Result Filtering — 置信度过滤规则(必须遵守)
核心原则:只返回高置信度结果,低置信度结果一律丢弃,绝不编造或推测。
| Score 范围 | 处理方式 |
|---|---|
| ≥ 0.7 | 高置信度 — 正常返回给用户,可放心引用 |
| 0.4 ~ 0.7 | 中置信度 — 仅作为辅助参考,需明确标注"相关性中等,仅供参考" |
| < 0.4 | 低置信度 — 必须丢弃,不返回给用户 |
执行流程:
- 查询返回 JSON 后,检查
Nodes列表 - 如果
Nodes为空或所有 Node 的 Score < 0.4 → 直接告诉用户:"知识库中未找到相关内容",不要猜测或编造 - 过滤掉 Score < 0.4 的 Node,只保留 ≥ 0.4 的结果
- 对 0.4~0.7 的结果标注置信度等级,≥ 0.7 的正常呈现
- 绝对禁止补充知识库没有的信息,具体包括:
- 禁止推断缺失字段:如果原始数据中某个字段为空(如类别、标题等),必须如实呈现为空,不得根据代码前缀、名称含义、常识等推断填充。空字段就是空字段,如实展示
- 禁止凭常识补充:不得用自身知识补充知识库未涵盖的内容(如操作步骤、定义解释、背景知识等)
- 禁止拼凑完整回答:不得用低置信度片段拼凑出看似完整的回答
- 禁止强行关联:不得将不相关内容强行关联用户问题
- 一句话原则:只呈现知识库原文中有的内容,原文没有的一字不加
- 绝对禁止向用户暴露内部处理过程:不得在输出中出现任何关于 Score阈值、过滤条数、保留条数、最高/最低Score、丢弃/保留等内部逻辑的描述。用户只看到最终结论,不看到中间过程。违反此规则等同于向用户泄露系统内部信息
Output Format — 输出格式规则(必须遵守)
向用户呈现检索结果时,必须在回答末尾标注信息来源:
- 回答正文:整理并呈现过滤后的高/中置信度结果,不包含任何 Score 数值或过滤过程描述
- 末尾追加来源标注,格式如下:
---
**信息来源:**
- 《文档名1》
- 《文档名2》 (仅供参考)
- 来源标注规则:
- 从每个保留的 Node 的
Metadata.doc_name提取文档名 - 同一文档名只列一次(去重)
- 高置信度(≥0.7)只列文档名
- 中置信度(0.4~0.7)额外标注"仅供参考"
- 如果有页码信息(
page_number),附上页码,如:《文档名》第2页 - 来源标注中不得出现 Score 数值
- 从每个保留的 Node 的
- 知识库未找到相关内容时,来源标注为:
**信息来源:** 知识库中无匹配文档
Error Handling
| Exit Code | Meaning | Fix |
|---|---|---|
| 1 | Missing query argument | Provide query string as first positional arg |
| 1 | Config file read error | Check -config path and file permissions |
| 1 | Config parse error | Validate JSON format in config.json |
| 1 | Client creation failed | Check AK/SK correctness |
| 1 | Retrieve API failed | Check workspace_id / knowledge_index_id validity |
Build
如需重新编译:
cd scripts
go mod tidy
# macOS
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o ../bin/bailian-query-mac .
# Linux amd64 (交叉编译)
GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o ../bin/bailian-query-linux .
# Windows amd64 (交叉编译)
GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o ../bin/bailian-query-win64.exe .
What ships with it: 9 files
14432.9 KB alongside SKILL.md, 2 of them executable
bin/
- bailian-query-linuxruns7199.8 KB
- bailian-query-macruns7199.8 KB
- config.json.example260 B
- .gitignore571 B
- README.md6.5 KB
- VERSION5 B