|
|
@@ -1,17 +1,22 @@
|
|
|
-from pydantic import BaseModel
|
|
|
+from pydantic import BaseModel, field_validator
|
|
|
|
|
|
|
|
|
class KnowledgeBaseItem(BaseModel):
|
|
|
id: str
|
|
|
name: str
|
|
|
- parent_table: str
|
|
|
- child_table: str
|
|
|
+ parent_table: str = ""
|
|
|
+ child_table: str = ""
|
|
|
document_count: int
|
|
|
status: str
|
|
|
created_at: str
|
|
|
created_by: str
|
|
|
metadata_schema: list[dict] = []
|
|
|
|
|
|
+ @field_validator("parent_table", "child_table", mode="before")
|
|
|
+ @classmethod
|
|
|
+ def none_to_empty(cls, v: str | None) -> str:
|
|
|
+ return v if v is not None else ""
|
|
|
+
|
|
|
|
|
|
class KnowledgeBaseListResponse(BaseModel):
|
|
|
total: int
|
|
|
@@ -24,8 +29,8 @@ class KnowledgeBaseDetailResponse(BaseModel):
|
|
|
id: str
|
|
|
name: str
|
|
|
description: str = ""
|
|
|
- parent_table: str
|
|
|
- child_table: str
|
|
|
+ parent_table: str = ""
|
|
|
+ child_table: str = ""
|
|
|
document_count: int
|
|
|
status: str
|
|
|
created_at: str
|
|
|
@@ -33,6 +38,11 @@ class KnowledgeBaseDetailResponse(BaseModel):
|
|
|
created_by: str
|
|
|
metadata_schema: list[dict] = []
|
|
|
|
|
|
+ @field_validator("parent_table", "child_table", mode="before")
|
|
|
+ @classmethod
|
|
|
+ def none_to_empty(cls, v: str | None) -> str:
|
|
|
+ return v if v is not None else ""
|
|
|
+
|
|
|
|
|
|
class ImportTaskResponse(BaseModel):
|
|
|
task_id: str
|
|
|
@@ -44,5 +54,10 @@ class KbImportResponse(BaseModel):
|
|
|
kb_name: str
|
|
|
document_count: int
|
|
|
metadata_schema: list[dict] = []
|
|
|
- parent_table: str
|
|
|
- child_table: str
|
|
|
+ parent_table: str = ""
|
|
|
+ child_table: str = ""
|
|
|
+
|
|
|
+ @field_validator("parent_table", "child_table", mode="before")
|
|
|
+ @classmethod
|
|
|
+ def none_to_empty(cls, v: str | None) -> str:
|
|
|
+ return v if v is not None else ""
|