Skip to content

Commit

Permalink
move to prebuilt
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jan 10, 2025
1 parent 8534212 commit d27beee
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 66 deletions.
65 changes: 65 additions & 0 deletions libs/langgraph/langgraph/prebuilt/interrupt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class HumanInterruptConfig(TypedDict):

Check notice on line 1 in libs/langgraph/langgraph/prebuilt/interrupt.py

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

......................................... fanout_to_subgraph_10x: Mean +- std dev: 61.1 ms +- 1.3 ms ......................................... fanout_to_subgraph_10x_sync: Mean +- std dev: 53.1 ms +- 0.6 ms ......................................... fanout_to_subgraph_10x_checkpoint: Mean +- std dev: 74.6 ms +- 1.2 ms ......................................... fanout_to_subgraph_10x_checkpoint_sync: Mean +- std dev: 95.3 ms +- 1.8 ms ......................................... fanout_to_subgraph_100x: Mean +- std dev: 610 ms +- 23 ms ......................................... fanout_to_subgraph_100x_sync: Mean +- std dev: 518 ms +- 12 ms ......................................... fanout_to_subgraph_100x_checkpoint: Mean +- std dev: 763 ms +- 15 ms ......................................... fanout_to_subgraph_100x_checkpoint_sync: Mean +- std dev: 961 ms +- 18 ms ......................................... react_agent_10x: Mean +- std dev: 30.7 ms +- 0.7 ms ......................................... react_agent_10x_sync: Mean +- std dev: 22.9 ms +- 0.2 ms ......................................... react_agent_10x_checkpoint: Mean +- std dev: 38.1 ms +- 0.8 ms ......................................... react_agent_10x_checkpoint_sync: Mean +- std dev: 36.8 ms +- 0.4 ms ......................................... react_agent_100x: Mean +- std dev: 341 ms +- 6 ms ......................................... react_agent_100x_sync: Mean +- std dev: 271 ms +- 3 ms ......................................... react_agent_100x_checkpoint: Mean +- std dev: 640 ms +- 7 ms ......................................... react_agent_100x_checkpoint_sync: Mean +- std dev: 620 ms +- 6 ms ......................................... wide_state_25x300: Mean +- std dev: 23.3 ms +- 0.4 ms ......................................... wide_state_25x300_sync: Mean +- std dev: 15.3 ms +- 0.1 ms ......................................... wide_state_25x300_checkpoint: Mean +- std dev: 248 ms +- 14 ms ......................................... wide_state_25x300_checkpoint_sync: Mean +- std dev: 245 ms +- 13 ms ......................................... wide_state_15x600: Mean +- std dev: 27.3 ms +- 0.6 ms ......................................... wide_state_15x600_sync: Mean +- std dev: 17.7 ms +- 0.2 ms ......................................... wide_state_15x600_checkpoint: Mean +- std dev: 428 ms +- 14 ms ......................................... wide_state_15x600_checkpoint_sync: Mean +- std dev: 424 ms +- 13 ms ......................................... wide_state_9x1200: Mean +- std dev: 27.3 ms +- 0.6 ms ......................................... wide_state_9x1200_sync: Mean +- std dev: 17.7 ms +- 0.1 ms ......................................... wide_state_9x1200_checkpoint: Mean +- std dev: 280 ms +- 14 ms ......................................... wide_state_9x1200_checkpoint_sync: Mean +- std dev: 275 ms +- 12 ms

Check notice on line 1 in libs/langgraph/langgraph/prebuilt/interrupt.py

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+-----------------------------------------+----------+-----------------------+ | Benchmark | main | changes | +=========================================+==========+=======================+ | react_agent_100x_checkpoint_sync | 684 ms | 620 ms: 1.10x faster | +-----------------------------------------+----------+-----------------------+ | fanout_to_subgraph_100x_checkpoint | 801 ms | 763 ms: 1.05x faster | +-----------------------------------------+----------+-----------------------+ | react_agent_100x_checkpoint | 670 ms | 640 ms: 1.05x faster | +-----------------------------------------+----------+-----------------------+ | fanout_to_subgraph_100x | 637 ms | 610 ms: 1.04x faster | +-----------------------------------------+----------+-----------------------+ | fanout_to_subgraph_10x_sync | 55.4 ms | 53.1 ms: 1.04x faster | +-----------------------------------------+----------+-----------------------+ | fanout_to_subgraph_100x_checkpoint_sync | 1.00 sec | 961 ms: 1.04x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_25x300_checkpoint | 258 ms | 248 ms: 1.04x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_15x600_sync | 18.4 ms | 17.7 ms: 1.04x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_25x300_sync | 15.8 ms | 15.3 ms: 1.04x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_25x300_checkpoint_sync | 253 ms | 245 ms: 1.03x faster | +-----------------------------------------+----------+-----------------------+ | react_agent_100x_sync | 280 ms | 271 ms: 1.03x faster | +-----------------------------------------+----------+-----------------------+ | react_agent_100x | 353 ms | 341 ms: 1.03x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_9x1200_checkpoint | 289 ms | 280 ms: 1.03x faster | +-----------------------------------------+----------+-----------------------+ | fanout_to_subgraph_10x | 63.1 ms | 61.1 ms: 1.03x faster | +-----------------------------------------+----------+-----------------------+ | fanout_to_subgraph_10x_checkpoint_sync | 98.2 ms | 95.3 ms: 1.03x faster | +-----------------------------------------+----------+-----------------------+ | fanout_to_subgraph_100x_sync | 533 ms | 518 ms: 1.03x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_9x1200_checkpoint_sync | 283 ms | 275 ms: 1.03x faster | +-----------------------------------------+----------+-----------------------+ | react_agent_10x_checkpoint_sync | 37.8 ms | 36.8 ms: 1.03x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_15x600_checkpoint | 440 ms | 428 ms: 1.03x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_15x600_checkpoint_sync | 434 ms | 424 ms: 1.02x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_15x600 | 27.9 ms | 27.3 ms: 1.02x faster | +-----------------------------------------+----------+-----------------------+ | react_agent_10x | 31.4 ms | 30.7 ms: 1.02x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_25x300 | 23.8 ms | 23.3 ms: 1.02x faster | +-----------------------------------------+----------+-----------------------+ | react_agent_10x_sync | 23.3 ms | 22.9 ms: 1.02x faster | +-----------------------------------------+----------+-----------------------+ | wide_state_9x1200_sync | 18.0 ms | 17.7 ms: 1.0
"""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]
66 changes: 0 additions & 66 deletions libs/langgraph/langgraph/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit d27beee

Please sign in to comment.