docs(knowledge): 强制添加知识库描述参数

- 升级知识库创建命令,`--description` 参数变为必填,描述知识库内容和用途
- 更新所有相关文档示例,统一加入 `--description` 参数和示例文本
- CLI 校验增强,缺失或超长的描述参数本地报错,避免服务端拒绝
- 优化服务创建命令,推荐填写描述以帮助 agent 选择合适服务
- 多个测试用例添加对描述参数的验证和断言
- 知识库和集合列表中描述信息作为区分同类项目的辅助信息显式展示
- 其他细节调整包括命令帮助及参数说明内容的更新
This commit is contained in:
zeyu.fz
2026-08-22 11:21:22 +08:00
parent 0a63115aed
commit a6291e00e1
21 changed files with 275 additions and 79 deletions
+6 -4
View File
@@ -128,7 +128,7 @@ bl knowledge info --index-id idx-xxx --workspace-id ws-xxx
**用法**
```bash
bl knowledge create --name <text> (--doc-id <id> | --category-id <id>) [flags]
bl knowledge create --name <text> --description <text> (--doc-id <id> | --category-id <id>) [flags]
```
**参数**
@@ -136,6 +136,7 @@ bl knowledge create --name <text> (--doc-id <id> | --category-id <id>) [flags]
| 参数 | 类型 | 必填 | 说明 |
| --------------------------- | ------ | ---- | -------------------------------------------------------- |
| `--name <text>` | string | 是 | 知识库名称(1-20 字符,工作区内唯一) |
| `--description <text>` | string | 是 | 知识库装了什么内容、给谁用(1-200 字符) |
| `--doc-id <id>` | array | 否¹ | 数据中心文件 ID(可重复);与 `--category-id` 互斥 |
| `--category-id <id>` | array | 否¹ | 按分类导入该分类下所有文件(可重复);与 `--doc-id` 互斥 |
| `--embedding-model <name>` | string | 否 | 向量模型名称(默认:`text-embedding-v4`) |
@@ -148,6 +149,7 @@ bl knowledge create --name <text> (--doc-id <id> | --category-id <id>) [flags]
**参数约束**
- `--name` 长度 1-20 字符
- `--description` 长度 1-200 字符,缺失或超长会在本地被拦截
- `--doc-id` 和 `--category-id` 互斥,必须提供其一
**输出**
@@ -176,13 +178,13 @@ json 模式:返回 API 原始响应,包含 `pipelineId`(知识库 ID)和
```bash
# 从指定文件创建知识库
bl knowledge create --name demo --doc-id file-xxx --workspace-id ws-xxx
bl knowledge create --name demo --description '产品文档' --doc-id file-xxx --workspace-id ws-xxx
# 从分类导入并等待导入完成
bl knowledge create --name demo --category-id cate-xxx --wait
bl knowledge create --name demo --description '产品文档' --category-id cate-xxx --wait
# 指定向量模型和切片大小
bl knowledge create --name my-kb --doc-id file-a --doc-id file-b --embedding-model text-embedding-v4 --chunk-size 400 --workspace-id ws-xxx
bl knowledge create --name my-kb --description '产品文档 v2' --doc-id file-a --doc-id file-b --embedding-model text-embedding-v4 --chunk-size 400 --workspace-id ws-xxx
```
---
+2 -2
View File
@@ -153,7 +153,7 @@ bl knowledge doc upload --file ./docs/intro.md --workspace-id ws-xxx
# → 返回 file-id
# 2. 用文件创建知识库
bl knowledge create --name my-kb --doc-id file-xxx --workspace-id ws-xxx --wait
bl knowledge create --name my-kb --description '产品文档' --doc-id file-xxx --workspace-id ws-xxx --wait
# → 返回 index-id (pipelineId) 和导入任务状态
# 3. 创建检索服务(search 场景)
@@ -245,7 +245,7 @@ bl knowledge doc import-oss \
# → 返回各文件的 fileId
# 2. 创建知识库并导入这些文件
bl knowledge create --name oss-kb --doc-id file-a --doc-id file-b --workspace-id ws-xxx --wait
bl knowledge create --name oss-kb --description 'OSS 导入文档' --doc-id file-a --doc-id file-b --workspace-id ws-xxx --wait
# 3. 检索
bl knowledge search --query "相关内容" --agent-id aid-xxx --workspace-id ws-xxx
+2 -2
View File
@@ -142,14 +142,14 @@ bl knowledge service create --name <text> --scene <chat|search> [flags]
| ------------------------ | ------ | ---- | ------------------------------------------------- |
| `--name <text>` | string | 是 | 服务名称(最多 200 字符,同一场景下工作区内唯一) |
| `--scene <chat\|search>` | string | 是 | 服务场景:`chat`(Q&A)或 `search`(检索) |
| `--description <text>` | string | 否 | 服务描述(最多 1000 字符) |
| `--description <text>` | string | 建议 | 这个服务能回答什么、给谁用(最多 1000 字符) |
| `--index-id <id>` | string | 否 | 绑定此知识库;其他配置使用服务端默认值 |
**参数约束**
- `--name` 最多 200 字符
- `--scene` 只能是 `chat` 或 `search`
- `--description` 最多 1000 字符
- `--description` 最多 1000 字符;建议填写 —— agent 靠它判断该调用哪个服务
**输出**