有赞开发者知识检索
开始前
本 Skill 随 @youzan/ai-toolkit 发布并同步到有赞云公网 npm 镜像,且内嵌在 CLI 中。执行检索前读取当前 CLI 版本携带的说明:
youzan-toolkit skills read yzy-open-knowledge-search
youzan-toolkit docs search --help
CLI 负责请求、参数校验、鉴权、TLS、结果缓存和结构化输出;本 Skill 负责场景判断和结果解释。
配置
发行包不包含内网地址或默认凭证。首次使用时配置可从公网访问的 HTTPS 服务:
youzan-toolkit config init --endpoint 'https://<public-service>/search'
也可以仅为当前进程使用环境变量:
export YOUZAN_TOOLKIT_ENDPOINT='https://<public-service>/search'
export YOUZAN_TOOLKIT_AUTHORIZATION='Bearer <token>'
命令行 --authorization 的优先级最高。查看状态不会输出真实凭证:
youzan-toolkit auth status
默认参数
| 字段 | 默认值 | 说明 |
|---|---|---|
text |
用户问题 | 检索文本 |
topN |
10 |
返回条数 |
hnswEf |
200 |
ef 取值范围 [1,32768] |
filters |
[] |
过滤条件 |
retrieveCategoryPath |
true |
返回类目路径 |
retrieveRawContent |
true |
返回原文档 |
retrievalType |
2 |
0 向量、1 关键词、2 混合 |
algRerank |
true |
算法重排 |
expandPrevChunks |
2 |
命中切片向上扩展数量 |
expandNextChunks |
2 |
命中切片向下扩展数量 |
mergeExpandedContent |
true |
合并扩展内容 |
maxExpandedChars |
3000 |
扩展内容最大长度 |
检索流程
- 提取用户的真实问题作为
--keyword。 - 用户指定
topN、retrievalType或filters时覆盖默认值。 - 调用
youzan-toolkit docs search。 - 优先使用高分结果、原文内容和类目路径回答。
- 需要完整文档时,从结果提取标识并调用
docs read。 - 结果不足以支撑结论时,明确说明没有检索到充分依据。
youzan-toolkit docs search --keyword '问题'
youzan-toolkit docs search --keyword '问题' --top-n 5 --retrieval-type 2
youzan-toolkit docs search --keyword '问题' --dry-run
youzan-toolkit docs read --id '<搜索结果 ID>'
youzan-toolkit openapi schema 'youzan.item.get'
输出要求
- 先基于检索结果给出结论,不只输出接口 JSON。
- 归纳关键依据,不编造服务未返回的事实。
- 默认使用 JSON 供 Agent 组合;面向人类时可使用
--format pretty。 - 用户要求原始结果时使用
--full-response。