23 lines
827 B
Python
23 lines
827 B
Python
"""暂停图并接收用户回答,不在恢复时重复调用模型"""
|
|
|
|
from langgraph.types import interrupt
|
|
|
|
from app.processor.base import BaseNode
|
|
from app.processor.state import QueryState
|
|
from app.schemas.clarification_reply import ClarificationReply
|
|
|
|
|
|
class WaitForUserNode(BaseNode):
|
|
name = "wait_for_user_node"
|
|
|
|
def process(self, state: QueryState) -> QueryState:
|
|
updated_state: QueryState = state.copy()
|
|
# 回复的格式与选项有效性已在恢复前由服务层校验,此处只还原为模型
|
|
reply = ClarificationReply.model_validate(
|
|
interrupt(state["clarification"].model_dump(mode="json"))
|
|
)
|
|
|
|
updated_state["clarification_reply"] = reply
|
|
updated_state["status"] = "cancelled" if reply.cancel else "running"
|
|
return updated_state
|