fix: Add the missing validation of doc_form in the service API. (#32892)

This commit is contained in:
FFXN
2026-03-03 15:54:43 +08:00
committed by GitHub
parent c8688ec371
commit 2068640a4b
4 changed files with 47 additions and 2 deletions

View File

@ -1,8 +1,9 @@
from enum import StrEnum
from typing import Literal
from pydantic import BaseModel
from pydantic import BaseModel, field_validator
from core.rag.index_processor.constant.index_type import IndexStructureType
from core.rag.retrieval.retrieval_methods import RetrievalMethod
@ -127,6 +128,18 @@ class KnowledgeConfig(BaseModel):
name: str | None = None
is_multimodal: bool = False
@field_validator("doc_form")
@classmethod
def validate_doc_form(cls, value: str) -> str:
valid_forms = [
IndexStructureType.PARAGRAPH_INDEX,
IndexStructureType.QA_INDEX,
IndexStructureType.PARENT_CHILD_INDEX,
]
if value not in valid_forms:
raise ValueError("Invalid doc_form.")
return value
class SegmentCreateArgs(BaseModel):
content: str | None = None