From 9cbbbb56a9a2505ad0f1ff96f8485db6b9a3d7a2 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Wed, 15 Apr 2026 00:06:44 +0800 Subject: [PATCH] =?UTF-8?q?SealAI=20=E7=9F=A5=E8=AF=86=E6=96=87=E6=A1=A3?= =?UTF-8?q?=20CLI=20=E5=B1=82=E8=A1=A5=E5=85=A8=EF=BC=88knowledge-list/get?= =?UTF-8?q?/create/update=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - knowledge_list.py:列表展示,支持 --scenario 过滤、--detail 展开正文 Markdown - knowledge_get.py:单篇详情,元信息表格 + Panel Markdown 渲染 - knowledge_create.py:新建文档,支持交互式输入正文(EOF 结束) - knowledge_update.py:更新文档,--enable/--disable 互斥开关控制启停状态 - 注册 4 条新命令到 commands/sealai/__init__.py - help.py 命令树同步更新 --- src/ekb_cli/api/sealai/knowledge_api.py | 132 ++++++++++++++++ src/ekb_cli/commands/help.py | 9 ++ src/ekb_cli/commands/sealai/__init__.py | 27 +++- .../commands/sealai/knowledge_create.py | 56 +++++++ src/ekb_cli/commands/sealai/knowledge_get.py | 63 ++++++++ src/ekb_cli/commands/sealai/knowledge_list.py | 70 +++++++++ .../commands/sealai/knowledge_update.py | 48 ++++++ .../services/sealai/knowledge_service.py | 143 ++++++++++++++++++ 8 files changed, 541 insertions(+), 7 deletions(-) create mode 100644 src/ekb_cli/api/sealai/knowledge_api.py create mode 100644 src/ekb_cli/commands/sealai/knowledge_create.py create mode 100644 src/ekb_cli/commands/sealai/knowledge_get.py create mode 100644 src/ekb_cli/commands/sealai/knowledge_list.py create mode 100644 src/ekb_cli/commands/sealai/knowledge_update.py create mode 100644 src/ekb_cli/services/sealai/knowledge_service.py diff --git a/src/ekb_cli/api/sealai/knowledge_api.py b/src/ekb_cli/api/sealai/knowledge_api.py new file mode 100644 index 0000000..f6af399 --- /dev/null +++ b/src/ekb_cli/api/sealai/knowledge_api.py @@ -0,0 +1,132 @@ +"""SealAI 知识文档 API 封装(传输层)。 + +已逆向确认端点: + GET /api/v1/knowledge/articles 文档列表(场景过滤 + 分页 + 排序) + POST /api/v1/knowledge/articles 新建文档 + GET /api/v1/knowledge/articles/{id} 文档详情 + PATCH /api/v1/knowledge/articles/{id} 更新文档(请求体为 {attributes: {...}}) + +注意:PATCH 请求体有特殊包装:{"attributes": {改动字段}},与 POST 直接传字段不同。 +""" + +from typing import Optional +from ekb_cli.api.sealai.client import SealAiClient +from ekb_cli.api.sealai.schemas import ( + SealAiResponse, + KnowledgeArticle, + KnowledgeArticleListData, +) + + +def list_articles( + client: SealAiClient, + *, + scenarios: Optional[list[str]] = None, + offset: int = 0, + limit: int = 20, + sort_by: str = "createdAt", + sort_order: str = "desc", +) -> KnowledgeArticleListData: + """获取知识文档列表。 + + Args: + scenarios: 场景过滤,如 ["audit"]、["fill"],None 表示不过滤 + offset: 分页偏移量(默认 0) + limit: 每页数量(默认 20) + sort_by: 排序字段(默认 createdAt) + sort_order: 排序方向,"asc" | "desc"(默认 desc) + """ + # 构造 filter[scenarios][N]=xxx 风格的 query 参数 + params: dict = { + "offset": offset, + "limit": limit, + "sortBy": sort_by, + "sortOrder": sort_order, + } + if scenarios: + for i, s in enumerate(scenarios): + params[f"filter[scenarios][{i}]"] = s + + raw = client.get("/api/v1/knowledge/articles", params=params) + return SealAiResponse[KnowledgeArticleListData].model_validate(raw).data + + +def get_article(client: SealAiClient, article_id: str) -> KnowledgeArticle: + """获取单篇知识文档详情。""" + raw = client.get(f"/api/v1/knowledge/articles/{article_id}") + return SealAiResponse[KnowledgeArticle].model_validate(raw).data + + +def create_article( + client: SealAiClient, + *, + title: str, + purpose: str, + content: str, + content_type: str = "policy", + status: str = "published", + scenarios: Optional[list[str]] = None, + tags: Optional[list[str]] = None, +) -> KnowledgeArticle: + """新建知识文档。 + + Args: + title: 文档标题 + purpose: 适用说明 + content: 正文内容(Markdown 格式) + content_type: 内容类型,默认 "policy" + status: "published" | "draft",默认 "published" + scenarios: 适用场景列表,如 ["audit", "fill"] + tags: 标签列表,"__all__" 表示全适用 + """ + body = { + "title": title, + "purpose": purpose, + "contentType": content_type, + "content": content, + "status": status, + "scenarios": scenarios or [], + "tags": tags or [], + } + raw = client.post("/api/v1/knowledge/articles", body) + return SealAiResponse[KnowledgeArticle].model_validate(raw).data + + +def patch_article( + client: SealAiClient, + article_id: str, + *, + title: Optional[str] = None, + purpose: Optional[str] = None, + content: Optional[str] = None, + content_type: Optional[str] = None, + status: Optional[str] = None, + enabled: Optional[bool] = None, + scenarios: Optional[list[str]] = None, + tags: Optional[list[str]] = None, +) -> KnowledgeArticle: + """更新知识文档(Patch 式,只传改动字段)。 + + 注意:PATCH 请求体格式为 {"attributes": {改动字段}}, + 与 POST 的直传字段格式不同,这里已在传输层做好封装。 + """ + attributes: dict = {} + if title is not None: + attributes["title"] = title + if purpose is not None: + attributes["purpose"] = purpose + if content is not None: + attributes["content"] = content + if content_type is not None: + attributes["contentType"] = content_type + if status is not None: + attributes["status"] = status + if enabled is not None: + attributes["enabled"] = enabled + if scenarios is not None: + attributes["scenarios"] = scenarios + if tags is not None: + attributes["tags"] = tags + + raw = client.patch(f"/api/v1/knowledge/articles/{article_id}", {"attributes": attributes}) + return SealAiResponse[KnowledgeArticle].model_validate(raw).data diff --git a/src/ekb_cli/commands/help.py b/src/ekb_cli/commands/help.py index 6f373dd..49c1217 100644 --- a/src/ekb_cli/commands/help.py +++ b/src/ekb_cli/commands/help.py @@ -40,6 +40,15 @@ COMMAND_TREE = { "_help": "SealAI 智能填单/审核平台管理", "whoami": "查看当前 SealAI 用户身份及租户信息", "billing": "查看当前企业 SealAI 订阅状态及功能配额", + "rules": "查看草稿区审核规则列表", + "rule-create": "新建草稿审核规则", + "rule-update": "更新草稿审核规则 → ekb sealai rule-update --help", + "rule-delete": "删除草稿审核规则 → ekb sealai rule-delete ", + "versions": "查看已发布规则集版本历史", + "knowledge-list": "查看知识文档列表 → ekb sealai knowledge-list --help", + "knowledge-get": "查看单篇知识文档详情 → ekb sealai knowledge-get ", + "knowledge-create": "新建知识文档 → ekb sealai knowledge-create --help", + "knowledge-update": "更新知识文档 → ekb sealai knowledge-update --help", }, } diff --git a/src/ekb_cli/commands/sealai/__init__.py b/src/ekb_cli/commands/sealai/__init__.py index e4dbce2..15d357b 100644 --- a/src/ekb_cli/commands/sealai/__init__.py +++ b/src/ekb_cli/commands/sealai/__init__.py @@ -1,13 +1,17 @@ """sealai 子命令组 对应 CLI 命令: - ekb sealai whoami → 查看当前 SealAI 用户身份及租户信息 - ekb sealai billing → 查看当前企业 SealAI 订阅状态及功能配额 - ekb sealai rules → 查看草稿区审核规则列表 - ekb sealai rule-create → 新建草稿审核规则 - ekb sealai rule-update → 更新草稿审核规则 - ekb sealai rule-delete → 删除草稿审核规则 - ekb sealai versions → 查看已发布规则集版本历史 + ekb sealai whoami → 查看当前 SealAI 用户身份及租户信息 + ekb sealai billing → 查看当前企业 SealAI 订阅状态及功能配额 + ekb sealai rules → 查看草稿区审核规则列表 + ekb sealai rule-create → 新建草稿审核规则 + ekb sealai rule-update → 更新草稿审核规则 + ekb sealai rule-delete → 删除草稿审核规则 + ekb sealai versions → 查看已发布规则集版本历史 + ekb sealai knowledge-list → 查看知识文档列表 + ekb sealai knowledge-get → 查看单篇知识文档详情 + ekb sealai knowledge-create → 新建知识文档 + ekb sealai knowledge-update → 更新知识文档 """ import typer @@ -18,6 +22,10 @@ from ekb_cli.commands.sealai.rule_create import cmd_rule_create from ekb_cli.commands.sealai.rule_update import cmd_rule_update from ekb_cli.commands.sealai.rule_delete import cmd_rule_delete from ekb_cli.commands.sealai.versions import cmd_versions +from ekb_cli.commands.sealai.knowledge_list import cmd_knowledge_list +from ekb_cli.commands.sealai.knowledge_get import cmd_knowledge_get +from ekb_cli.commands.sealai.knowledge_create import cmd_knowledge_create +from ekb_cli.commands.sealai.knowledge_update import cmd_knowledge_update app = typer.Typer(help="SealAI 智能填单/审核平台管理") @@ -28,3 +36,8 @@ app.command("rule-create")(cmd_rule_create) app.command("rule-update")(cmd_rule_update) app.command("rule-delete")(cmd_rule_delete) app.command("versions")(cmd_versions) +app.command("knowledge-list")(cmd_knowledge_list) +app.command("knowledge-get")(cmd_knowledge_get) +app.command("knowledge-create")(cmd_knowledge_create) +app.command("knowledge-update")(cmd_knowledge_update) + diff --git a/src/ekb_cli/commands/sealai/knowledge_create.py b/src/ekb_cli/commands/sealai/knowledge_create.py new file mode 100644 index 0000000..769922e --- /dev/null +++ b/src/ekb_cli/commands/sealai/knowledge_create.py @@ -0,0 +1,56 @@ +"""sealai knowledge-create:新建知识文档 + +表现层:交互式输入 + rich 输出。 +业务逻辑委托给 services.sealai.knowledge_service。 +""" + +import typer +from rich import print as rprint + +from ekb_cli.services.sealai import get_sealai_client, add_article + + +def cmd_knowledge_create( + corp_id: str = typer.Option(None, "--corp", "-c", help="指定企业 corpId,默认使用当前企业"), + title: str = typer.Option(None, "--title", "-t", help="文档标题"), + purpose: str = typer.Option(None, "--purpose", "-p", help="适用说明"), + content: str = typer.Option(None, "--content", help="正文内容(Markdown),不传则交互输入"), + content_type: str = typer.Option("policy", "--type", help="内容类型,默认 policy"), + status: str = typer.Option("published", "--status", help="状态:published / draft"), + scenarios: list[str] = typer.Option([], "--scenario", "-s", help="适用场景(可多次传),如 -s audit -s fill"), + tags: list[str] = typer.Option([], "--tag", help="标签(可多次传),如 --tag __all__"), +): + """新建知识文档""" + if title is None: + title = typer.prompt("文档标题").strip() + if purpose is None: + purpose = typer.prompt("适用说明").strip() + if not title or not purpose: + rprint("[red]标题和适用说明不能为空[/red]") + raise typer.Exit(1) + if content is None: + rprint("[dim]请输入正文内容(Markdown 格式),输入完毕后按 Enter 再输入 EOF 结束:[/dim]") + lines = [] + try: + while True: + line = input() + if line == "EOF": + break + lines.append(line) + except EOFError: + pass + content = "\n".join(lines) + + client = get_sealai_client(corp_id=corp_id) + article = add_article( + client, + title=title, + purpose=purpose, + content=content, + content_type=content_type, + status=status, + scenarios=list(scenarios) or None, + tags=list(tags) or None, + ) + rprint(f"[green]✓[/green] 文档已创建:[bold]{article.title}[/bold]") + rprint(f" ID:[dim]{article.id}[/dim]") diff --git a/src/ekb_cli/commands/sealai/knowledge_get.py b/src/ekb_cli/commands/sealai/knowledge_get.py new file mode 100644 index 0000000..db1d22d --- /dev/null +++ b/src/ekb_cli/commands/sealai/knowledge_get.py @@ -0,0 +1,63 @@ +"""sealai knowledge-get:查看单篇知识文档详情 + +表现层:只负责 rich 格式化输出。 +业务逻辑委托给 services.sealai.knowledge_service。 +""" + +import typer +from datetime import datetime, timezone +from rich.console import Console +from rich.panel import Panel +from rich.markdown import Markdown +from rich.table import Table +from rich import print as rprint + +from ekb_cli.services.sealai import get_sealai_client, get_article_detail + +console = Console() + +_SCENARIO_LABEL = { + "audit": "审核", + "fill": "填单", +} +_STATUS_LABEL = { + "published": "[green]已发布[/green]", + "draft": "[yellow]草稿[/yellow]", +} + + +def cmd_knowledge_get( + article_id: str = typer.Argument(..., help="文档 ID"), + corp_id: str = typer.Option(None, "--corp", "-c", help="指定企业 corpId,默认使用当前企业"), +): + """查看单篇知识文档详情(含正文 Markdown 渲染)""" + client = get_sealai_client(corp_id=corp_id) + a = get_article_detail(client, article_id) + + scenes = " / ".join(_SCENARIO_LABEL.get(s, s) for s in a.scenarios) + status = _STATUS_LABEL.get(a.status, a.status) + enabled = "[green]启用[/green]" if a.enabled else "[red]已禁用[/red]" + tags_str = "、".join(a.tags) if a.tags else "[dim]无[/dim]" + + # 元信息表格 + meta = Table.grid(padding=(0, 2)) + meta.add_column(style="dim") + meta.add_column() + meta.add_row("ID", a.id) + meta.add_row("标题", a.title) + meta.add_row("适用说明", a.purpose) + meta.add_row("内容类型", a.contentType) + meta.add_row("适用场景", scenes) + meta.add_row("标签", tags_str) + meta.add_row("状态", f"{status} {enabled}") + + if a.createdAt: + ts = datetime.fromtimestamp(a.createdAt / 1000, tz=timezone.utc).strftime("%Y-%m-%d %H:%M") + meta.add_row("创建时间", f"{ts} by {a.createdByName}") + if a.updatedAt: + ts = datetime.fromtimestamp(a.updatedAt / 1000, tz=timezone.utc).strftime("%Y-%m-%d %H:%M") + meta.add_row("更新时间", f"{ts} by {a.updatedByName}") + + console.print(meta) + console.print() + console.print(Panel(Markdown(a.content), title="[bold]正文内容[/bold]", border_style="dim")) diff --git a/src/ekb_cli/commands/sealai/knowledge_list.py b/src/ekb_cli/commands/sealai/knowledge_list.py new file mode 100644 index 0000000..1cef3e6 --- /dev/null +++ b/src/ekb_cli/commands/sealai/knowledge_list.py @@ -0,0 +1,70 @@ +"""sealai knowledge-list:查看知识文档列表 + +表现层:只负责 rich 格式化输出。 +业务逻辑委托给 services.sealai.knowledge_service。 +""" + +import typer +from datetime import datetime, timezone +from rich.console import Console +from rich.table import Table +from rich.panel import Panel +from rich.markdown import Markdown +from rich import print as rprint + +from ekb_cli.services.sealai import get_sealai_client, get_articles + +console = Console() + +_SCENARIO_LABEL = { + "audit": "审核", + "fill": "填单", +} +_STATUS_LABEL = { + "published": "[green]已发布[/green]", + "draft": "[yellow]草稿[/yellow]", +} + + +def cmd_knowledge_list( + corp_id: str = typer.Option(None, "--corp", "-c", help="指定企业 corpId,默认使用当前企业"), + scenario: str = typer.Option(None, "--scenario", "-s", help="按场景过滤:audit / fill"), + limit: int = typer.Option(20, "--limit", "-n", help="返回数量上限"), + detail: bool = typer.Option(False, "--detail", help="展开每篇文档的正文内容"), +): + """查看知识文档列表""" + scenarios = [scenario] if scenario else None + client = get_sealai_client(corp_id=corp_id) + data = get_articles(client, scenarios=scenarios, limit=limit) + + if not data.articles: + rprint("[yellow]暂无知识文档[/yellow]") + raise typer.Exit() + + if not detail: + table = Table(title=f"知识文档(共 {data.total or len(data.articles)} 篇)", show_lines=True) + table.add_column("ID", style="dim", no_wrap=True) + table.add_column("标题") + table.add_column("适用说明", max_width=30) + table.add_column("场景") + table.add_column("状态") + table.add_column("更新时间") + + for a in data.articles: + scenes = " / ".join(_SCENARIO_LABEL.get(s, s) for s in a.scenarios) + status = _STATUS_LABEL.get(a.status, a.status) + ts = datetime.fromtimestamp(a.updatedAt / 1000, tz=timezone.utc).strftime("%Y-%m-%d %H:%M") if a.updatedAt else "-" + table.add_row(a.id[:8] + "…", a.title, a.purpose, scenes, status, ts) + + console.print(table) + console.print("[dim]查看正文内容:ekb sealai knowledge-list --detail[/dim]") + console.print("[dim]查看单篇详情:ekb sealai knowledge-get [/dim]") + else: + for a in data.articles: + scenes = " / ".join(_SCENARIO_LABEL.get(s, s) for s in a.scenarios) + status = _STATUS_LABEL.get(a.status, a.status) + console.print(Panel( + Markdown(a.content), + title=f"[bold]{a.title}[/bold] {status} [dim]{scenes}[/dim]", + subtitle=f"[dim]ID: {a.id}[/dim]", + )) diff --git a/src/ekb_cli/commands/sealai/knowledge_update.py b/src/ekb_cli/commands/sealai/knowledge_update.py new file mode 100644 index 0000000..e55a8e4 --- /dev/null +++ b/src/ekb_cli/commands/sealai/knowledge_update.py @@ -0,0 +1,48 @@ +"""sealai knowledge-update:更新知识文档 + +表现层:只负责参数解析 + rich 输出。 +业务逻辑委托给 services.sealai.knowledge_service。 +""" + +import typer +from typing import Optional +from rich import print as rprint + +from ekb_cli.services.sealai import get_sealai_client, edit_article + + +def cmd_knowledge_update( + article_id: str = typer.Argument(..., help="文档 ID"), + corp_id: str = typer.Option(None, "--corp", "-c", help="指定企业 corpId,默认使用当前企业"), + title: str = typer.Option(None, "--title", "-t", help="新标题"), + purpose: str = typer.Option(None, "--purpose", "-p", help="新适用说明"), + content: str = typer.Option(None, "--content", help="新正文内容(Markdown)"), + content_type: str = typer.Option(None, "--type", help="新内容类型"), + status: str = typer.Option(None, "--status", help="新状态:published / draft"), + enable: bool = typer.Option(None, "--enable/--disable", help="启用或停用文档"), + scenarios: Optional[list[str]] = typer.Option(None, "--scenario", "-s", help="新适用场景(可多次传,会整体替换)"), + tags: Optional[list[str]] = typer.Option(None, "--tag", help="新标签(可多次传,会整体替换)"), +): + """更新知识文档(只传需要修改的字段)""" + # enable 是 Optional[bool],typer 的 --enable/--disable 未传时值为 None + any_field = any([title, purpose, content, content_type, status, scenarios, tags, enable is not None]) + if not any_field: + rprint("[yellow]未指定任何修改字段,无需更新[/yellow]") + raise typer.Exit() + + client = get_sealai_client(corp_id=corp_id) + article = edit_article( + client, + article_id, + title=title, + purpose=purpose, + content=content, + content_type=content_type, + status=status, + enabled=enable, + scenarios=list(scenarios) if scenarios is not None else None, + tags=list(tags) if tags is not None else None, + ) + enabled_str = "[green]启用[/green]" if article.enabled else "[red]已停用[/red]" + rprint(f"[green]✓[/green] 文档已更新:[bold]{article.title}[/bold] {enabled_str}") + rprint(f" ID:[dim]{article.id}[/dim]") diff --git a/src/ekb_cli/services/sealai/knowledge_service.py b/src/ekb_cli/services/sealai/knowledge_service.py new file mode 100644 index 0000000..e404090 --- /dev/null +++ b/src/ekb_cli/services/sealai/knowledge_service.py @@ -0,0 +1,143 @@ +"""SealAI 知识文档业务逻辑层。 + +管理知识文档的增删改查。 +知识文档是 AI 审批的训练素材,支持按场景(audit/fill)分类, +内容以 Markdown 格式存储,前端可渲染。 +""" + +from typing import Optional +from ekb_cli.api.sealai.client import SealAiClient +from ekb_cli.api.sealai.knowledge_api import ( + list_articles, + get_article, + create_article, + patch_article, +) +from ekb_cli.api.sealai.schemas import ( + KnowledgeArticle, + KnowledgeArticleListData, +) + +# 合法场景值 +_VALID_SCENARIOS = {"audit", "fill"} +# 合法状态值 +_VALID_STATUSES = {"published", "draft"} + + +def get_articles( + client: SealAiClient, + *, + scenarios: Optional[list[str]] = None, + offset: int = 0, + limit: int = 20, + sort_by: str = "createdAt", + sort_order: str = "desc", +) -> KnowledgeArticleListData: + """查询知识文档列表。 + + Args: + scenarios: 按场景过滤,可选值 "audit" | "fill",None 表示不过滤 + offset: 分页偏移量(默认 0) + limit: 每页数量(默认 20,建议不超过 100) + sort_by: 排序字段(默认 createdAt) + sort_order: "asc" | "desc"(默认 desc,最新在前) + """ + if scenarios: + _validate_scenarios(scenarios) + return list_articles( + client, + scenarios=scenarios, + offset=offset, + limit=limit, + sort_by=sort_by, + sort_order=sort_order, + ) + + +def get_article_detail(client: SealAiClient, article_id: str) -> KnowledgeArticle: + """查询单篇知识文档详情。""" + return get_article(client, article_id) + + +def add_article( + client: SealAiClient, + *, + title: str, + purpose: str, + content: str, + content_type: str = "policy", + status: str = "published", + scenarios: Optional[list[str]] = None, + tags: Optional[list[str]] = None, +) -> KnowledgeArticle: + """新建知识文档。 + + Args: + title: 文档标题 + purpose: 适用说明 + content: 正文(Markdown 格式) + content_type: 内容类型,默认 "policy" + status: "published" | "draft",默认 "published" + scenarios: 适用场景,如 ["audit", "fill"] + tags: 标签列表,"__all__" 表示全部适用 + """ + if status not in _VALID_STATUSES: + from ekb_cli.errors import EkbError + raise EkbError(f"status 无效:{status!r},合法值为 {sorted(_VALID_STATUSES)}", code=422) + if scenarios: + _validate_scenarios(scenarios) + return create_article( + client, + title=title, + purpose=purpose, + content=content, + content_type=content_type, + status=status, + scenarios=scenarios, + tags=tags, + ) + + +def edit_article( + client: SealAiClient, + article_id: str, + *, + title: Optional[str] = None, + purpose: Optional[str] = None, + content: Optional[str] = None, + content_type: Optional[str] = None, + status: Optional[str] = None, + enabled: Optional[bool] = None, + scenarios: Optional[list[str]] = None, + tags: Optional[list[str]] = None, +) -> KnowledgeArticle: + """更新知识文档(只传需要改动的字段)。""" + if status is not None and status not in _VALID_STATUSES: + from ekb_cli.errors import EkbError + raise EkbError(f"status 无效:{status!r},合法值为 {sorted(_VALID_STATUSES)}", code=422) + if scenarios is not None: + _validate_scenarios(scenarios) + return patch_article( + client, + article_id, + title=title, + purpose=purpose, + content=content, + content_type=content_type, + status=status, + enabled=enabled, + scenarios=scenarios, + tags=tags, + ) + + +# ── 内部校验 ────────────────────────────────────────────────────────────────── + +def _validate_scenarios(scenarios: list[str]) -> None: + invalid = set(scenarios) - _VALID_SCENARIOS + if invalid: + from ekb_cli.errors import EkbError + raise EkbError( + f"scenarios 包含无效值:{sorted(invalid)},合法值为 {sorted(_VALID_SCENARIOS)}", + code=422, + )