Repository navigation
feat(knowledge): 支持手工知识创建时传入自定义元数据 - #5488
Open
Shinku-Chen wants to merge 2 commits into
Open
Shinku-Chen wants to merge 2 commits into
Shinku-Chen wants to merge 2 commits into
Conversation
Accept optional custom_metadata on manual creation and persist it with the body. Reuse metadata validation and document create/update behavior with regression tests. Assisted-by: Cindy (https://cindy.app)
Limit custom_metadata support to manual creation and remove the additional manual-update rejection, its test and unrelated documentation changes. Assisted-by: Cindy (https://cindy.app)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
中文说明
让手工 Markdown 创建接口在首次入库时同时保存自定义元数据,调用方可以一次提交正文和来源属性,减少一次后续属性更新请求。
接口
POST /api/v1/knowledge-bases/{id}/knowledge/manual新增可选请求字段
custom_metadata,与正文一起写入同一条 Knowledge 的首次 INSERT:{ "title": "版本指南", "content": "完整的 Markdown 正文。", "status": "publish", "custom_metadata": { "source_id": "9007199254740993", "version": "1" } }行为与限制
status: "publish";HTTP 成功不等于索引已经完成。custom_metadata与内部手工正文 metadata 分开保存,不拼入正文向量化输入;已有摘要和上下文使用元数据的行为保持不变。English
Manual Markdown creation previously ignored
custom_metadata, requiring callers to create the knowledge first and send a separate property update. This change accepts optional custom metadata onPOST /api/v1/knowledge-bases/{id}/knowledge/manualand stores it in the same initial Knowledge insert as the document body.Compatibility: this change only adds metadata persistence to manual creation. It introduces no new rejection or metadata-editing behavior on the existing update routes.
Example creation body:
{ "title": "Release guide", "content": "# Guide\nFull document body", "status": "publish", "custom_metadata": {"source_id": "9007199254740993", "version": "1"} }Assisted-by: Cindy (https://cindy.app)
Type of Change
Related Issue
N/A — no upstream issue is associated with this change.
Testing
中文验证摘要
已验证 HTTP JSON 绑定、非法参数在副作用前返回 400、字段数量/字节限制、省略/null/空对象、draft/publish 的 SQLite 落库与读回、大整数原始 JSON 保存,以及原有正文更新、通用元数据更新和索引内容边界。Swagger 契约测试及差异范围 lint 通过。单 PR 验证使用隔离 SQLite 和假队列,未调用真实模型或部署知识库;PostgreSQL 与完整 make 检查未执行,既有 Python 环境依赖用例显式排除。
English
Passed:
Focused tests cover HTTP JSON binding and validation-error propagation, metadata limits (including multibyte byte limits), rejection before side effects, omitted/null/empty metadata, draft/publish SQLite persistence, raw large-number preservation, body-only update preservation, and existing metadata/index-content behavior. A separate regression locks down the generic property's existing null handling and invalid-input rejection contract. Publish tests use a fake queue; no models or deployed knowledge bases are invoked.
Swagger was generated with the repository-pinned swag v1.16.6. Only the new request property is retained, avoiding unrelated generator ordering changes; the Swagger contract tests pass. Changed Go files are formatted, and diff-scoped golangci-lint v2.12.2 reports zero new findings.
TestSkillPythonVerifieris the existing environment-dependent Python verifier excluded from the affected-package command. Fullmake fmt,make lint,make test, real PostgreSQL, provider calls and deployment are NOT_RUN. Validation is scoped to the changed feature and affected packages.Checklist
git diff --check origin/main...HEADpassesgolangci-lint run --new-from-rev=origin/main ./...)website-docs/, Swagger annotations, etc.)Screenshots / Recordings
N/A — no UI changes.