Skip to content

Commit a6291e0

Browse files
committed
docs(knowledge): 强制添加知识库描述参数
- 升级知识库创建命令,`--description` 参数变为必填,描述知识库内容和用途 - 更新所有相关文档示例,统一加入 `--description` 参数和示例文本 - CLI 校验增强,缺失或超长的描述参数本地报错,避免服务端拒绝 - 优化服务创建命令,推荐填写描述以帮助 agent 选择合适服务 - 多个测试用例添加对描述参数的验证和断言 - 知识库和集合列表中描述信息作为区分同类项目的辅助信息显式展示 - 其他细节调整包括命令帮助及参数说明内容的更新
1 parent 0a63115 commit a6291e0

21 files changed

Lines changed: 275 additions & 79 deletions

docs/knowledge/kb.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,15 @@ bl knowledge info --index-id idx-xxx --workspace-id ws-xxx
128128
**用法**
129129

130130
```bash
131-
bl knowledge create --name <text> (--doc-id <id> | --category-id <id>) [flags]
131+
bl knowledge create --name <text> --description <text> (--doc-id <id> | --category-id <id>) [flags]
132132
```
133133

134134
**参数**
135135

136136
| 参数 | 类型 | 必填 | 说明 |
137137
| --------------------------- | ------ | ---- | -------------------------------------------------------- |
138138
| `--name <text>` | string || 知识库名称(1-20 字符,工作区内唯一) |
139+
| `--description <text>` | string || 知识库装了什么内容、给谁用(1-200 字符) |
139140
| `--doc-id <id>` | array | 否¹ | 数据中心文件 ID(可重复);与 `--category-id` 互斥 |
140141
| `--category-id <id>` | array | 否¹ | 按分类导入该分类下所有文件(可重复);与 `--doc-id` 互斥 |
141142
| `--embedding-model <name>` | string || 向量模型名称(默认:`text-embedding-v4`|
@@ -148,6 +149,7 @@ bl knowledge create --name <text> (--doc-id <id> | --category-id <id>) [flags]
148149
**参数约束**
149150

150151
- `--name` 长度 1-20 字符
152+
- `--description` 长度 1-200 字符,缺失或超长会在本地被拦截
151153
- `--doc-id``--category-id` 互斥,必须提供其一
152154

153155
**输出**
@@ -176,13 +178,13 @@ json 模式:返回 API 原始响应,包含 `pipelineId`(知识库 ID)和
176178

177179
```bash
178180
# 从指定文件创建知识库
179-
bl knowledge create --name demo --doc-id file-xxx --workspace-id ws-xxx
181+
bl knowledge create --name demo --description '产品文档' --doc-id file-xxx --workspace-id ws-xxx
180182

181183
# 从分类导入并等待导入完成
182-
bl knowledge create --name demo --category-id cate-xxx --wait
184+
bl knowledge create --name demo --description '产品文档' --category-id cate-xxx --wait
183185

184186
# 指定向量模型和切片大小
185-
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
187+
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
186188
```
187189

188190
---

docs/knowledge/knowledge-cli-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ bl knowledge doc upload --file ./docs/intro.md --workspace-id ws-xxx
153153
# → 返回 file-id
154154

155155
# 2. 用文件创建知识库
156-
bl knowledge create --name my-kb --doc-id file-xxx --workspace-id ws-xxx --wait
156+
bl knowledge create --name my-kb --description '产品文档' --doc-id file-xxx --workspace-id ws-xxx --wait
157157
# → 返回 index-id (pipelineId) 和导入任务状态
158158

159159
# 3. 创建检索服务(search 场景)
@@ -245,7 +245,7 @@ bl knowledge doc import-oss \
245245
# → 返回各文件的 fileId
246246

247247
# 2. 创建知识库并导入这些文件
248-
bl knowledge create --name oss-kb --doc-id file-a --doc-id file-b --workspace-id ws-xxx --wait
248+
bl knowledge create --name oss-kb --description 'OSS 导入文档' --doc-id file-a --doc-id file-b --workspace-id ws-xxx --wait
249249

250250
# 3. 检索
251251
bl knowledge search --query "相关内容" --agent-id aid-xxx --workspace-id ws-xxx

docs/knowledge/service.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ bl knowledge service create --name <text> --scene <chat|search> [flags]
142142
| ------------------------ | ------ | ---- | ------------------------------------------------- |
143143
| `--name <text>` | string || 服务名称(最多 200 字符,同一场景下工作区内唯一) |
144144
| `--scene <chat\|search>` | string || 服务场景:`chat`(Q&A)或 `search`(检索) |
145-
| `--description <text>` | string | | 服务描述(最多 1000 字符) |
145+
| `--description <text>` | string | 建议 | 这个服务能回答什么、给谁用(最多 1000 字符) |
146146
| `--index-id <id>` | string || 绑定此知识库;其他配置使用服务端默认值 |
147147

148148
**参数约束**
149149

150150
- `--name` 最多 200 字符
151151
- `--scene` 只能是 `chat``search`
152-
- `--description` 最多 1000 字符
152+
- `--description` 最多 1000 字符;建议填写 —— agent 靠它判断该调用哪个服务
153153

154154
**输出**
155155

packages/commands/src/commands/knowledge/collection-create.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ const COLLECTION_CREATE_FLAGS = {
2020
type: "string",
2121
valueHint: "<text>",
2222
description: {
23-
"en-US": "Collection description (required by the server)",
24-
"zh-CN": "数据集合描述(服务端必填)",
23+
"en-US":
24+
"What this collection holds and what it is for — tells collections apart in the list",
25+
"zh-CN": "数据集合装了什么内容、给谁用,用于在列表中区分同类集合",
2526
},
2627
required: true,
2728
},

packages/commands/src/commands/knowledge/kb-create.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ const KB_CREATE_FLAGS = {
2929
},
3030
required: true,
3131
},
32+
description: {
33+
type: "string",
34+
valueHint: "<text>",
35+
description: {
36+
"en-US":
37+
"What this knowledge base holds and what it is for — tells bases apart in the workspace list (1-200 chars)",
38+
"zh-CN": "知识库装了什么内容、给谁用,用于在 Workspace 列表中区分同类知识库(1–200 个字符)",
39+
},
40+
required: true,
41+
},
3242
docId: {
3343
type: "array",
3444
valueHint: "<id>",
@@ -107,7 +117,7 @@ export default defineCommand({
107117
"zh-CN": "创建知识库并导入数据中心文件或类目",
108118
},
109119
auth: "apiKey",
110-
usageArgs: "--name <text> (--doc-id <id> | --category-id <id>) [flags]",
120+
usageArgs: "--name <text> --description <text> (--doc-id <id> | --category-id <id>) [flags]",
111121
flags: KB_CREATE_FLAGS,
112122
notes: [
113123
{
@@ -126,11 +136,20 @@ export default defineCommand({
126136
},
127137
],
128138
exampleArgs: [
129-
"--name demo --doc-id file-xxx --workspace-id ws-xxx",
130-
"--name demo --category-id cate-xxx --wait",
139+
{
140+
"en-US": "--name demo --description 'product docs' --doc-id file-xxx --workspace-id ws-xxx",
141+
"zh-CN": "--name demo --description '产品文档' --doc-id file-xxx --workspace-id ws-xxx",
142+
},
143+
{
144+
"en-US": "--name demo --description 'product docs' --category-id cate-xxx --wait",
145+
"zh-CN": "--name demo --description '产品文档' --category-id cate-xxx --wait",
146+
},
131147
],
132148
validate(flags) {
133149
if (flags.name.length < 1 || flags.name.length > 20) return "--name must be 1-20 characters";
150+
if (flags.description.length < 1 || flags.description.length > 200) {
151+
return "--description must be 1-200 characters";
152+
}
134153
const hasDocIds = !!flags.docId?.length;
135154
const hasCategoryIds = !!flags.categoryId?.length;
136155
if (hasDocIds && hasCategoryIds) return "Use either --doc-id or --category-id, not both";
@@ -147,6 +166,9 @@ export default defineCommand({
147166
// Note: the public docs' example uses sinkType DEFAULT, but BUILT_IN is what works against the live API.
148167
const body = {
149168
name: flags.name,
169+
// The server enforces description as a required 1-200 char field (the public
170+
// API docs still list it as absent from CreateIndexV2Request.required).
171+
description: flags.description,
150172
structureType: "unstructured",
151173
sinkType: "BUILT_IN",
152174
embeddingModelName: flags.embeddingModel ?? "text-embedding-v4",

packages/commands/src/commands/knowledge/retrieve.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ export default defineCommand({
8282
auth: "apiKey",
8383
usageArgs: "--index-id <id> --query <text> [flags]",
8484
flags: RETRIEVE_FLAGS,
85+
notes: [
86+
{
87+
"en-US":
88+
"--rerank-model requires the target knowledge base to already have a rerank model configured; otherwise every value is rejected.",
89+
"zh-CN": "--rerank-model 要求目标知识库已配置重排序模型,否则任何取值都会被拒绝。",
90+
},
91+
],
8592
exampleArgs: [
8693
{
8794
"en-US": '--index-id idx_xxx --query "How to use Alibaba Cloud Bailian"',

packages/commands/src/commands/knowledge/service-create.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ const SERVICE_CREATE_FLAGS = {
3232
type: "string",
3333
valueHint: "<text>",
3434
description: {
35-
"en-US": "Service description (up to 1000 chars)",
36-
"zh-CN": "服务描述(最多 1000 个字符)",
35+
"en-US":
36+
"What this service answers and who it serves — recommended: agents read it to pick the right service (up to 1000 chars)",
37+
"zh-CN":
38+
"这个服务能回答什么、给谁用 —— 建议填写:agent 靠它判断该调用哪个服务(最多 1000 个字符)",
3739
},
3840
},
3941
indexId: {
@@ -71,7 +73,11 @@ export default defineCommand({
7173
},
7274
],
7375
exampleArgs: [
74-
"--name my-qa --scene chat --workspace-id ws-xxx",
76+
{
77+
"en-US":
78+
"--name my-qa --scene chat --description 'answers product FAQs' --workspace-id ws-xxx",
79+
"zh-CN": "--name my-qa --scene chat --description '回答产品常见问题' --workspace-id ws-xxx",
80+
},
7581
"--name my-search --scene search --index-id idx-xxx",
7682
],
7783
validate(flags) {

packages/commands/src/commands/knowledge/service-list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const SERVICE_LIST_FLAGS = {
1414
type: "string",
1515
valueHint: "<scene>",
1616
description: {
17-
"en-US": "Service scene: chat (Q&A) or search (retrieval). Required by the server",
18-
"zh-CN": "服务场景:chat(问答)或 search(检索),服务端必填",
17+
"en-US": "Service scene: chat (Q&A) or search (retrieval)",
18+
"zh-CN": "服务场景:chat(问答)或 search(检索)",
1919
},
2020
required: true,
2121
},

packages/commands/src/commands/knowledge/service-update.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,15 @@ const KNOWN_CONFIG_KEYS = new Set([
201201
"session_file_max_parse_length",
202202
"enable_kb_router",
203203
"kb_router_model",
204+
"user_system_prompt",
205+
"anti_leak_prompt",
206+
"refusal_prompt",
207+
"credibility_prompt",
208+
"enable_thinking",
209+
"enable_temperature",
210+
"enable_credibility",
211+
"enable_max_completion_tokens",
212+
"session_file_parse_mode",
204213
"rerank_top_n",
205214
"hybrid_rerank",
206215
"kb_search_configs",

packages/commands/tests/e2e/knowledge/journeys/journey-helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ export async function createKbWithDocs(
323323
"create",
324324
"--name",
325325
kbName,
326+
"--description",
327+
`journey ${journeyId} fixture knowledge base (safe to delete)`,
326328
...fileIds.flatMap((fileId) => ["--doc-id", fileId]),
327329
"--workspace-id",
328330
workspaceId,

0 commit comments

Comments
 (0)