feat: 完成input_context节点
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
"""输入协议的公共类型"""
|
||||
|
||||
from typing import Annotated
|
||||
|
||||
from pydantic import AfterValidator, BaseModel, ConfigDict, JsonValue
|
||||
|
||||
|
||||
def require_non_blank(value: str) -> str:
|
||||
if not value.strip():
|
||||
raise ValueError("不能为空或仅包含空白字符")
|
||||
return value
|
||||
|
||||
|
||||
NonBlankString = Annotated[str, AfterValidator(require_non_blank)]
|
||||
JsonObject = dict[str, JsonValue]
|
||||
|
||||
|
||||
class ExtensibleModel(BaseModel):
|
||||
"""校验已知字段,保留未知 JSON 字段;不隐式转换输入类型"""
|
||||
|
||||
model_config = ConfigDict(extra="allow", strict=True, allow_inf_nan=False)
|
||||
|
||||
__pydantic_extra__: dict[str, JsonValue]
|
||||
Reference in New Issue
Block a user