mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-12 12:47:53 +02:00
doc updates (#1639)
--------- Co-authored-by: vbarda <vadym@langchain.dev>
This commit is contained in:
co-authored by
vbarda
parent
38a644cf79
commit
db306cd01b
@@ -17,7 +17,9 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"First, we'll set up our environment."
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"First, let's install the required packages and set our API keys"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -27,8 +29,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %%capture --no-stderr\n",
|
||||
"# %pip install -U langgraph langchain langchain_openai"
|
||||
"%%capture --no-stderr\n",
|
||||
"%pip install -U langgraph langchain langchain_openai"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -47,13 +49,20 @@
|
||||
" os.environ[var] = getpass.getpass(f\"Please provide your {var}\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"_set_if_undefined(\"OPENAI_API_KEY\")\n",
|
||||
"_set_if_undefined(\"LANGCHAIN_API_KEY\")\n",
|
||||
"\n",
|
||||
"# Optional, add tracing in LangSmith.\n",
|
||||
"# This will help you visualize and debug the control flow\n",
|
||||
"os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||
"os.environ[\"LANGCHAIN_PROJECT\"] = \"Agent Simulation Evaluation\""
|
||||
"_set_if_undefined(\"OPENAI_API_KEY\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "95c9332f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<div class=\"admonition tip\">\n",
|
||||
" <p class=\"admonition-title\">Set up <a href=\"https://smith.langchain.com\">LangSmith</a> for LangGraph development</p>\n",
|
||||
" <p style=\"padding-top: 5px;\">\n",
|
||||
" Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started <a href=\"https://docs.smith.langchain.com\">here</a>. \n",
|
||||
" </p>\n",
|
||||
"</div> "
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -61,7 +70,7 @@
|
||||
"id": "6ef4528d-6b2a-47c7-98b5-50f14984a304",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 1. Define Chat Bot\n",
|
||||
"## Define Chat Bot\n",
|
||||
"\n",
|
||||
"Next, we will define our chat bot. For this notebook, we assume the bot's API accepts a list of messages and responds with a message. If you want to update this, all you'll have to change is this section and the \"get_messages_for_agent\" function in \n",
|
||||
"the simulator below.\n",
|
||||
@@ -123,7 +132,7 @@
|
||||
"id": "419340a3-5ecf-48e7-9028-4f2fad750502",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 2. Define Simulated User\n",
|
||||
"## Define Simulated User\n",
|
||||
"\n",
|
||||
"We're now going to define the simulated user. \n",
|
||||
"This can be anything we want, but we're going to build it as a LangChain bot."
|
||||
@@ -192,7 +201,7 @@
|
||||
"id": "321312b4-a1f0-4454-a481-fdac4e37cb7d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 3. Define the Agent Simulation\n",
|
||||
"## Define the Agent Simulation\n",
|
||||
"\n",
|
||||
"The code below creates a LangGraph workflow to run the simulation. The main components are:\n",
|
||||
"\n",
|
||||
@@ -207,7 +216,7 @@
|
||||
"id": "65bc4446-462b-4ee8-b017-2862fbbdfaf5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Nodes**\n",
|
||||
"### Define nodes\n",
|
||||
"\n",
|
||||
"First, we define the nodes in the graph. These should take in a list of messages and return a list of messages to ADD to the state.\n",
|
||||
"These will be thing wrappers around the chat bot and simulated user we have above.\n",
|
||||
@@ -278,7 +287,7 @@
|
||||
"id": "a48d8a3e-9171-4c43-a595-44d312722148",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Edges**\n",
|
||||
"### Define edges\n",
|
||||
"\n",
|
||||
"We now need to define the logic for the edges. The main logic occurs after the simulated user goes, and it should lead to one of two outcomes:\n",
|
||||
"\n",
|
||||
@@ -310,7 +319,7 @@
|
||||
"id": "d0856d4f-9334-4f28-944b-06d303e913a4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Graph**\n",
|
||||
"### Define graph\n",
|
||||
"\n",
|
||||
"We can now define the graph that sets up the simulation!"
|
||||
]
|
||||
@@ -358,7 +367,7 @@
|
||||
"id": "2e0bd26e-8c1d-471d-9fef-d95dc0163491",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 4. Run Simulation\n",
|
||||
"## Run Simulation\n",
|
||||
"\n",
|
||||
"Now we can evaluate our chat bot! We can invoke it with empty messages (this will simulate letting the chat bot start the initial conversation)"
|
||||
]
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
"\n",
|
||||
"Building on our [previous example](./agent-simulation-evaluation.ipynb), we can show how to use simulated conversations to benchmark your chat bot using LangSmith.\n",
|
||||
"\n",
|
||||
"First, we'll install the prerequisites."
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"First, let's install the required packages and set our API keys"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -39,12 +41,20 @@
|
||||
" os.environ[var] = getpass.getpass(f\"Please provide your {var}\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"_set_if_undefined(\"OPENAI_API_KEY\")\n",
|
||||
"_set_if_undefined(\"LANGCHAIN_API_KEY\")\n",
|
||||
"\n",
|
||||
"# Optional, add tracing in LangSmith.\n",
|
||||
"# This will help you visualize and debug the control flow\n",
|
||||
"os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\""
|
||||
"_set_if_undefined(\"OPENAI_API_KEY\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f84b7874",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<div class=\"admonition tip\">\n",
|
||||
" <p class=\"admonition-title\">Set up <a href=\"https://smith.langchain.com\">LangSmith</a> for LangGraph development</p>\n",
|
||||
" <p style=\"padding-top: 5px;\">\n",
|
||||
" Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started <a href=\"https://docs.smith.langchain.com\">here</a>. \n",
|
||||
" </p>\n",
|
||||
"</div> "
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user