codekingpro/portable-devtools
114k
1from typing import Literal2 3from langgraph.warnings import LangGraphDeprecatedSinceV104from typing_extensions import TypedDict, deprecated5 6 7@deprecated(8 "HumanInterruptConfig has been moved to `langchain.agents.interrupt`. Please update your import to `from langchain.agents.interrupt import HumanInterruptConfig`.",9 category=LangGraphDeprecatedSinceV10,10)11class HumanInterruptConfig(TypedDict):12 """Configuration that defines what actions are allowed for a human interrupt.13 14 This controls the available interaction options when the graph is paused for human input.15 16 Attributes:17 allow_ignore: Whether the human can choose to ignore/skip the current step18 allow_respond: Whether the human can provide a text response/feedback19 allow_edit: Whether the human can edit the provided content/state20 allow_accept: Whether the human can accept/approve the current state21 """22 23 allow_ignore: bool24 allow_respond: bool25 allow_edit: bool26 allow_accept: bool27 28 29@deprecated(30 "ActionRequest has been moved to `langchain.agents.interrupt`. Please update your import to `from langchain.agents.interrupt import ActionRequest`.",31 category=LangGraphDeprecatedSinceV10,32)33class ActionRequest(TypedDict):34 """Represents a request for human action within the graph execution.35 36 Contains the action type and any associated arguments needed for the action.37 38 Attributes:39 action: The type or name of action being requested (e.g., `"Approve XYZ action"`)40 args: Key-value pairs of arguments needed for the action41 """42 43 action: str44 args: dict45 46 47@deprecated(48 "HumanInterrupt has been moved to `langchain.agents.interrupt`. Please update your import to `from langchain.agents.interrupt import HumanInterrupt`.",49 category=LangGraphDeprecatedSinceV10,50)51class HumanInterrupt(TypedDict):52 """Represents an interrupt triggered by the graph that requires human intervention.53 54 This is passed to the `interrupt` function when execution is paused for human input.55 56 Attributes:57 action_request: The specific action being requested from the human58 config: Configuration defining what actions are allowed59 description: Optional detailed description of what input is needed60 61 Example:62 ```python63 # Extract a tool call from the state and create an interrupt request64 request = HumanInterrupt(65 action_request=ActionRequest(66 action="run_command", # The action being requested67 args={"command": "ls", "args": ["-l"]} # Arguments for the action68 ),69 config=HumanInterruptConfig(70 allow_ignore=True, # Allow skipping this step71 allow_respond=True, # Allow text feedback72 allow_edit=False, # Don't allow editing73 allow_accept=True # Allow direct acceptance74 ),75 description="Please review the command before execution"76 )77 # Send the interrupt request and get the response78 response = interrupt([request])[0]79 ```80 """81 82 action_request: ActionRequest83 config: HumanInterruptConfig84 description: str | None85 86 87class HumanResponse(TypedDict):88 """The response provided by a human to an interrupt, which is returned when graph execution resumes.89 90 Attributes:91 type: The type of response:92 93 - `'accept'`: Approves the current state without changes94 - `'ignore'`: Skips/ignores the current step95 - `'response'`: Provides text feedback or instructions96 - `'edit'`: Modifies the current state/content97 args: The response payload:98 99 - `None`: For ignore/accept actions100 - `str`: For text responses101 - `ActionRequest`: For edit actions with updated content102 """103 104 type: Literal["accept", "ignore", "response", "edit"]105 args: None | str | ActionRequest106 