WIP-CHECKPOINT[auth-refactor]: 固化工程师崩溃前部分成果 + 同树其他未提交WIP(仅源码,不含密钥/二进制)-- 待重激活工程师续作
This commit is contained in:
@@ -35,7 +35,7 @@ class MessageCreate(BaseModel):
|
||||
file_size: 文件大小(字节,文件消息时使用)
|
||||
"""
|
||||
|
||||
content: str = Field(..., min_length=1, description="消息内容")
|
||||
content: str = Field(default="", description="消息内容")
|
||||
# 支持文本、图片、文件类型
|
||||
msg_type: str = Field(default="text", description="消息类型: text/image/file")
|
||||
# M1 新增:文件上传相关字段
|
||||
@@ -47,8 +47,11 @@ class MessageCreate(BaseModel):
|
||||
|
||||
@field_validator("msg_type")
|
||||
@classmethod
|
||||
def validate_msg_type(cls, v: str) -> str:
|
||||
def validate_msg_type(cls, v: Optional[str]) -> str:
|
||||
"""校验消息类型是否合法。"""
|
||||
# 处理 None 或 undefined 的情况
|
||||
if v is None or v == "undefined":
|
||||
return "text"
|
||||
if v not in VALID_MSG_TYPES:
|
||||
raise ValueError(f"无效的消息类型: {v},合法值为: {VALID_MSG_TYPES}")
|
||||
return v
|
||||
|
||||
Reference in New Issue
Block a user