From d27beeed187060256ff5baa88685bb08926077eb Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 10 Jan 2025 10:45:22 -0800 Subject: [PATCH] move to prebuilt --- .../langgraph/langgraph/prebuilt/interrupt.py | 65 ++++++++++++++++++ libs/langgraph/langgraph/types.py | 66 ------------------- 2 files changed, 65 insertions(+), 66 deletions(-) create mode 100644 libs/langgraph/langgraph/prebuilt/interrupt.py diff --git a/libs/langgraph/langgraph/prebuilt/interrupt.py b/libs/langgraph/langgraph/prebuilt/interrupt.py new file mode 100644 index 000000000..bf440f210 --- /dev/null +++ b/libs/langgraph/langgraph/prebuilt/interrupt.py @@ -0,0 +1,65 @@ +class HumanInterruptConfig(TypedDict): + """Configuration that defines what actions are allowed for a human interrupt. + + This controls the available interaction options when the graph is paused for human input. + + Attributes: + allow_ignore (bool): Whether the human can choose to ignore/skip the current step + allow_respond (bool): Whether the human can provide a text response/feedback + allow_edit (bool): Whether the human can edit the provided content/state + allow_accept (bool): Whether the human can accept/approve the current state + """ + + allow_ignore: bool + allow_respond: bool + allow_edit: bool + allow_accept: bool + + +class ActionRequest(TypedDict): + """Represents a request for human action within the graph execution. + + Contains the action type and any associated arguments needed for the action. + + Attributes: + action (str): The type or name of action being requested (e.g., "Approve XYZ action") + args (dict): Key-value pairs of arguments needed for the action + """ + + action: str + args: dict + + +class HumanInterrupt(TypedDict): + """Represents an interrupt triggered by the graph that requires human intervention. + + This is passed to the `interrupt` function when execution is paused for human input. + + Attributes: + action_request (ActionRequest): The specific action being requested from the human + config (HumanInterruptConfig): Configuration defining what actions are allowed + description (Optional[str]): Optional detailed description of what input is needed + """ + + action_request: ActionRequest + config: HumanInterruptConfig + description: Optional[str] + + +class HumanResponse(TypedDict): + """The response provided by a human to an interrupt, which is returned when graph execution resumes. + + Attributes: + type (Literal['accept', 'ignore', 'response', 'edit']): The type of response: + - "accept": Approves the current state without changes + - "ignore": Skips/ignores the current step + - "response": Provides text feedback or instructions + - "edit": Modifies the current state/content + args (Union[None, str, ActionRequest]): The response payload: + - None: For ignore/accept actions + - str: For text responses + - ActionRequest: For edit actions with updated content + """ + + type: Literal["accept", "ignore", "response", "edit"] + args: Union[None, str, ActionRequest] diff --git a/libs/langgraph/langgraph/types.py b/libs/langgraph/langgraph/types.py index d6d778e58..9a2c78acd 100644 --- a/libs/langgraph/langgraph/types.py +++ b/libs/langgraph/langgraph/types.py @@ -492,69 +492,3 @@ def node(state: State): ) ) - -class HumanInterruptConfig(TypedDict): - """Configuration that defines what actions are allowed for a human interrupt. - - This controls the available interaction options when the graph is paused for human input. - - Attributes: - allow_ignore (bool): Whether the human can choose to ignore/skip the current step - allow_respond (bool): Whether the human can provide a text response/feedback - allow_edit (bool): Whether the human can edit the provided content/state - allow_accept (bool): Whether the human can accept/approve the current state - """ - - allow_ignore: bool - allow_respond: bool - allow_edit: bool - allow_accept: bool - - -class ActionRequest(TypedDict): - """Represents a request for human action within the graph execution. - - Contains the action type and any associated arguments needed for the action. - - Attributes: - action (str): The type or name of action being requested (e.g., "Approve XYZ action") - args (dict): Key-value pairs of arguments needed for the action - """ - - action: str - args: dict - - -class HumanInterrupt(TypedDict): - """Represents an interrupt triggered by the graph that requires human intervention. - - This is passed to the `interrupt` function when execution is paused for human input. - - Attributes: - action_request (ActionRequest): The specific action being requested from the human - config (HumanInterruptConfig): Configuration defining what actions are allowed - description (Optional[str]): Optional detailed description of what input is needed - """ - - action_request: ActionRequest - config: HumanInterruptConfig - description: Optional[str] - - -class HumanResponse(TypedDict): - """The response provided by a human to an interrupt, which is returned when graph execution resumes. - - Attributes: - type (Literal['accept', 'ignore', 'response', 'edit']): The type of response: - - "accept": Approves the current state without changes - - "ignore": Skips/ignores the current step - - "response": Provides text feedback or instructions - - "edit": Modifies the current state/content - args (Union[None, str, ActionRequest]): The response payload: - - None: For ignore/accept actions - - str: For text responses - - ActionRequest: For edit actions with updated content - """ - - type: Literal["accept", "ignore", "response", "edit"] - args: Union[None, str, ActionRequest]