mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
fix: align knowledge base CRUD API contract with kb_name, canonical payload fields, and matching OpenAPI types (#9000)
Warning: Potential breaking changes in /kb related openapi. * fix(kb): align CRUD API contract end-to-end Unify knowledge base create/update/list with kb_name, canonical_payload, optional list pagination with total, and matching OpenAPI plus dashboard types. * fix: restore _model_dict references, add KnowledgeBaseCreateRequest, fix OpenAPI allOf validation - Replace 3 remaining _model_dict() calls with payload.model_dump(exclude_none=True) - Add KnowledgeBaseCreateRequest schema with required kb_name + embedding_provider_id - Remove additionalProperties: false from OpenAPI allOf sub-schema to avoid validation failures - Use Pydantic Field(alias="name") + populate_by_name=True for legacy name migration - Delegate _canonical_kb_payload to KnowledgeBaseRequest to eliminate duplicated logic - Add getattr default None for update_kb to prevent AttributeError - Add validation error tests: missing kb_name, missing embedding_provider_id * fix: address knowledge base contract follow-ups * fix: preserve knowledge base create error shape
This commit is contained in:
@@ -3381,7 +3381,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/KnowledgeBaseRequest"
|
||||
$ref: "#/components/schemas/KnowledgeBaseCreateRequest"
|
||||
responses:
|
||||
"200":
|
||||
$ref: "#/components/responses/Ok"
|
||||
@@ -5705,22 +5705,40 @@ components:
|
||||
|
||||
KnowledgeBaseRequest:
|
||||
type: object
|
||||
required: [name]
|
||||
properties:
|
||||
name:
|
||||
kb_name:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
emoji:
|
||||
type: string
|
||||
embedding_provider_id:
|
||||
type: string
|
||||
type: [string, "null"]
|
||||
rerank_provider_id:
|
||||
type: string
|
||||
chunking:
|
||||
$ref: "#/components/schemas/DynamicConfig"
|
||||
metadata:
|
||||
$ref: "#/components/schemas/DynamicConfig"
|
||||
type: [string, "null"]
|
||||
chunk_size:
|
||||
type: integer
|
||||
chunk_overlap:
|
||||
type: integer
|
||||
top_k_dense:
|
||||
type: integer
|
||||
top_k_sparse:
|
||||
type: integer
|
||||
top_m_final:
|
||||
type: integer
|
||||
additionalProperties: false
|
||||
|
||||
KnowledgeBaseCreateRequest:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/KnowledgeBaseRequest"
|
||||
- type: object
|
||||
required: [kb_name, embedding_provider_id]
|
||||
properties:
|
||||
kb_name:
|
||||
type: string
|
||||
embedding_provider_id:
|
||||
type: string
|
||||
|
||||
KnowledgeDocumentUploadRequest:
|
||||
type: object
|
||||
required: [file]
|
||||
@@ -5728,8 +5746,6 @@ components:
|
||||
file:
|
||||
type: string
|
||||
format: binary
|
||||
parser:
|
||||
type: string
|
||||
|
||||
KnowledgeDocumentImportRequest:
|
||||
type: object
|
||||
|
||||
Reference in New Issue
Block a user