25 lines
817 B
Python
25 lines
817 B
Python
"""用户恢复澄清流程时提交的内容"""
|
|
|
|
from typing import Self
|
|
|
|
from pydantic import model_validator
|
|
|
|
from app.schemas.base import ExtensibleModel, NonBlankString
|
|
from app.schemas.request import RequestContext
|
|
from app.schemas.screen import Screen
|
|
|
|
|
|
class ClarificationReply(ExtensibleModel):
|
|
answer: NonBlankString | None = None
|
|
option_id: NonBlankString | None = None
|
|
cancel: bool = False
|
|
# 不传时沿用暂停前的快照,传入时完整替换对应字段
|
|
screen: Screen | None = None
|
|
context: RequestContext | None = None
|
|
|
|
@model_validator(mode="after")
|
|
def require_answer(self) -> Self:
|
|
if not self.cancel and self.answer is None and self.option_id is None:
|
|
raise ValueError("请提供回答,或设置 cancel=true 取消")
|
|
return self
|