Skip to content

Commit

Permalink
Merge pull request #2708 from langchain-ai/eugene/wait_for_user_input…
Browse files Browse the repository at this point in the history
…_improve

wait for user input improvements
  • Loading branch information
eyurtsev authored Dec 11, 2024
2 parents f0f3e11 + 0cb530e commit cb225dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
24 changes: 11 additions & 13 deletions docs/docs/how-tos/human_in_the_loop/wait-user-input.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53",
"metadata": {},
"source": [
"# How to wait for user input\n",
"# How to wait for user input using `interrupt`\n",
"\n",
"!!! tip \"Prerequisites\"\n",
"\n",
Expand All @@ -17,7 +17,7 @@
" * [LangGraph Glossary](../../../concepts/low_level)\n",
" \n",
"\n",
"Human-in-the-loop (HIL) interactions are crucial for [agentic systems](https://langchain-ai.github.io/langgraph/concepts/agentic_concepts/#human-in-the-loop). Waiting for human input is a common HIL interaction pattern, allowing the agent to ask the user clarifying questions and await input before proceeding. \n",
"**Human-in-the-loop (HIL)** interactions are crucial for [agentic systems](https://langchain-ai.github.io/langgraph/concepts/agentic_concepts/#human-in-the-loop). Waiting for human input is a common HIL interaction pattern, allowing the agent to ask the user clarifying questions and await input before proceeding. \n",
"\n",
"We can implement this in LangGraph using [`interrupt()`][langgraph.types.interrupt]: `interrupt` allows us to stop graph execution to collect input from a user and continue execution with collected input."
]
Expand Down Expand Up @@ -98,13 +98,13 @@
"source": [
"## Simple Usage\n",
"\n",
"Let's look at very basic usage of this. One intuitive approach is simply to create a node, `human_feedback`, that will get user feedback. This allows us to place our feedback gathering at a specific, chosen point in our graph.\n",
" \n",
"1) We call `interrupt()` inside our `human_feedback` node.\n",
"Let's explore a basic example of using human feedback. A straightforward approach is to create a node, **`human_feedback`**, designed specifically to collect user input. This allows us to gather feedback at a specific, chosen point in our graph.\n",
"\n",
"2) We set up a [checkpointer](https://langchain-ai.github.io/langgraph/concepts/low_level/#checkpointer) to save the state of the graph up until this node.\n",
"Steps:\n",
"\n",
"3) We use `Command(resume=...)` to provide the requested value to the human feedback node and resume execution."
"1. **Call `interrupt()`** inside the **`human_feedback`** node. \n",
"2. **Set up a [checkpointer](https://langchain-ai.github.io/langgraph/concepts/low_level/#checkpointer)** to save the graph's state up to this node. \n",
"3. **Use `Command(resume=...)`** to provide the requested value to the **`human_feedback`** node and resume execution."
]
},
{
Expand Down Expand Up @@ -281,21 +281,19 @@
},
{
"cell_type": "markdown",
"id": "e36f89e5",
"id": "b22b9598-7ce4-4d16-b932-bba2bc2803ec",
"metadata": {},
"source": [
"## Agent\n",
"\n",
"In the context of agents, waiting for user feedback is useful to ask clarifying questions.\n",
" \n",
"To show this, we will build a relatively simple ReAct-style agent that does tool calling. \n",
"In the context of [agents](../../../concepts/agentic_concepts), waiting for user feedback is especially useful for asking clarifying questions. To illustrate this, we’ll create a simple [ReAct-style agent](../../../concepts/agentic_concepts#react-implementation) capable of [tool calling](https://python.langchain.com/docs/concepts/tool_calling/). \n",
"\n",
"We will use Anthropic's models and a fake tool (just for demo purposes)."
"For this example, we’ll use Anthropic's chat model along with a **mock tool** (purely for demonstration purposes)."
]
},
{
"cell_type": "markdown",
"id": "b3b8b7e5",
"id": "01789855-b769-426d-a329-3cdb29684df8",
"metadata": {},
"source": [
"<div class=\"admonition note\">\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/how-tos/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ LangGraph makes it easy to manage conversation [memory](../concepts/memory.md) i
you to involve humans in the decision-making process of your graph. These how-to guides show how to implement human-in-the-loop workflows in your graph.

- [How to edit graph state](human_in_the_loop/edit-graph-state.ipynb)
- [How to wait for user input](human_in_the_loop/wait-user-input.ipynb)
- [How to wait for user input using `interrupt`](human_in_the_loop/wait-user-input.ipynb)
- [How to view and update past graph state](human_in_the_loop/time-travel.ipynb)
- [How to review tool calls](human_in_the_loop/review-tool-calls.ipynb)
- [How to add static breakpoints](human_in_the_loop/breakpoints.ipynb): Use for debugging purposes. For [**human-in-the-loop**](../concepts/human_in_the_loop.md) workflows, we recommend the [`interrupt()`](../../../reference/types/#langgraph.types.interrupt) function instead.
Expand Down

0 comments on commit cb225dd

Please sign in to comment.