Refactor payload to ensure validated parser_config usage

Updated payload construction to always use validated parser_config.
This commit is contained in:
Billy Bao 2025-11-17 11:38:59 +08:00 committed by GitHub
parent ada337ef2b
commit 8d09b403e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -412,7 +412,6 @@ class KnowledgebaseService(CommonService):
return {"code": RetCode.DATA_ERROR, "message": "Tenant does not exist."}
# Build payload
parser_config = get_parser_config(parser_id, kwargs.get("parser_config"))
kb_id = get_uuid()
payload = {
"id": kb_id,
@ -420,11 +419,10 @@ class KnowledgebaseService(CommonService):
"tenant_id": tenant_id,
"created_by": tenant_id,
"parser_id": (parser_id or "naive"),
"parser_config": parser_config,
**kwargs
**kwargs # Includes optional fields such as description, language, permission, avatar, parser_config, etc.
}
# Default parser_config (align with kb_app.create) — do not accept external overrides
# Update parser_config (always override with validated default/merged config)
payload["parser_config"] = get_parser_config(parser_id, kwargs.get("parser_config"))
return payload