This commit is contained in:
Isaac Francisco
2024-08-14 17:16:00 -07:00
committed by GitHub
parent 2dbfc8aca3
commit 8ad797e261
+28 -35
View File
@@ -1256,19 +1256,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 7,
"id": "5a81608a-373a-4339-b1c6-65b73a92b983",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/wfh/code/lc/langchain/libs/core/langchain_core/_api/beta_decorator.py:87: LangChainBetaWarning: The method `ChatAnthropic.bind_tools` is in beta. It is actively being worked on, so the API may change.\n",
" warn_beta(\n"
]
}
],
"outputs": [],
"source": [
"from typing import Annotated\n",
"\n",
@@ -1320,12 +1311,12 @@
"id": "813505b2-18c1-46e9-b891-20a34232808b",
"metadata": {},
"source": [
"Now, compile the graph, specifying to `interrupt_before` the `action` node."
"Now, compile the graph, specifying to `interrupt_before` the `tools` node."
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 8,
"id": "b0883e32-1a39-4ce9-ae32-bbd66708fd84",
"metadata": {},
"outputs": [],
@@ -1334,14 +1325,14 @@
" checkpointer=memory,\n",
" # This is new!\n",
" interrupt_before=[\"tools\"],\n",
" # Note: can also interrupt __after__ actions, if desired.\n",
" # Note: can also interrupt __after__ tools, if desired.\n",
" # interrupt_after=[\"tools\"]\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 9,
"id": "9f318020-ab7e-415b-a5e2-eddec6d9f3a6",
"metadata": {},
"outputs": [
@@ -1354,10 +1345,10 @@
"I'm learning LangGraph. Could you do some research on it for me?\n",
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
"\n",
"[{'text': \"Okay, let's do some research on LangGraph:\", 'type': 'text'}, {'id': 'toolu_01Be7aRgMEv9cg6ezaFjiCry', 'input': {'query': 'LangGraph'}, 'name': 'tavily_search_results_json', 'type': 'tool_use'}]\n",
"[{'text': \"Okay, let's look up some information on LangGraph:\", 'type': 'text'}, {'id': 'toolu_01XoHVKTRbipJokQorfifzvh', 'input': {'query': 'LangGraph'}, 'name': 'tavily_search_results_json', 'type': 'tool_use'}]\n",
"Tool Calls:\n",
" tavily_search_results_json (toolu_01Be7aRgMEv9cg6ezaFjiCry)\n",
" Call ID: toolu_01Be7aRgMEv9cg6ezaFjiCry\n",
" tavily_search_results_json (toolu_01XoHVKTRbipJokQorfifzvh)\n",
" Call ID: toolu_01XoHVKTRbipJokQorfifzvh\n",
" Args:\n",
" query: LangGraph\n"
]
@@ -1385,17 +1376,17 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 10,
"id": "9bb7af46-9b4f-4bb1-b8b9-e9ddf7dbc82c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"('action',)"
"('tools',)"
]
},
"execution_count": 4,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -1410,12 +1401,12 @@
"id": "89326046-2b11-4812-8b6d-8780306ec275",
"metadata": {},
"source": [
"**Notice** that unlike last time, the \"next\" node is set to **'action'**. We've interrupted here! Let's check the tool invocation."
"**Notice** that unlike last time, the \"next\" node is set to **'tools'**. We've interrupted here! Let's check the tool invocation."
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 11,
"id": "3facda0a-e6ad-4b28-b627-753ad8c90c15",
"metadata": {},
"outputs": [
@@ -1424,10 +1415,11 @@
"text/plain": [
"[{'name': 'tavily_search_results_json',\n",
" 'args': {'query': 'LangGraph'},\n",
" 'id': 'toolu_01Be7aRgMEv9cg6ezaFjiCry'}]"
" 'id': 'toolu_01XoHVKTRbipJokQorfifzvh',\n",
" 'type': 'tool_call'}]"
]
},
"execution_count": 5,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@@ -1449,7 +1441,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 12,
"id": "effb95d9-b7d5-40c5-9253-253d193b23b2",
"metadata": {},
"outputs": [
@@ -1460,18 +1452,19 @@
"=================================\u001b[1m Tool Message \u001b[0m=================================\n",
"Name: tavily_search_results_json\n",
"\n",
"[{\"url\": \"https://github.com/langchain-ai/langgraph\", \"content\": \"LangGraph is a Python package that extends LangChain Expression Language with the ability to coordinate multiple chains across multiple steps of computation in a cyclic manner. It is inspired by Pregel and Apache Beam and can be used for agent-like behaviors, such as chatbots, with LLMs.\"}, {\"url\": \"https://langchain-ai.github.io/langgraph//\", \"content\": \"LangGraph is a library for building stateful, multi-actor applications with LLMs, built on top of (and intended to be used with) LangChain . It extends the LangChain Expression Language with the ability to coordinate multiple chains (or actors) across multiple steps of computation in a cyclic manner. It is inspired by Pregel and Apache Beam .\"}]\n",
"[{\"url\": \"https://langchain-ai.github.io/langgraph/tutorials/\", \"content\": \"LangGraph is a framework for building language agents as graphs. Learn how to use LangGraph to create chatbots, code assistants, planning agents, reflection agents, and more with these notebooks.\"}, {\"url\": \"https://github.com/langchain-ai/langgraph\", \"content\": \"LangGraph is a library for creating stateful, multi-actor applications with LLMs, using cycles, controllability, and persistence. Learn how to use LangGraph with examples, integration with LangChain, and streaming support.\"}]\n",
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
"\n",
"Based on the search results, LangGraph seems to be a Python library that extends the LangChain library to enable more complex, multi-step interactions with large language models (LLMs). Some key points:\n",
"Based on the search results, LangGraph seems to be a framework for building language-based AI agents and applications using language models. It provides a modular, graph-based approach for creating chatbots, code assistants, planning agents, and other language-centric applications.\n",
"\n",
"- LangGraph allows coordinating multiple \"chains\" (or actors) over multiple steps of computation, in a cyclic manner. This enables more advanced agent-like behaviors like chatbots.\n",
"- It is inspired by distributed graph processing frameworks like Pregel and Apache Beam.\n",
"- LangGraph is built on top of the LangChain library, which provides a framework for building applications with LLMs.\n",
"Some key things I learned about LangGraph:\n",
"\n",
"So in summary, LangGraph appears to be a powerful tool for building more sophisticated applications and agents using large language models, by allowing you to coordinate multiple steps and actors in a flexible, graph-like manner. It extends the capabilities of the base LangChain library.\n",
"- It is designed to make it easier to build stateful, multi-actor applications using large language models (LLMs).\n",
"- It provides features like cycles, controllability, and persistence to help manage the complexity of these types of applications.\n",
"- LangGraph can be integrated with the LangChain library, which provides additional tools for building LLM-powered applications.\n",
"- The framework includes examples and tutorials to help get started with using LangGraph.\n",
"\n",
"Let me know if you need any clarification or have additional questions!\n"
"Overall, LangGraph seems like a promising approach for building more advanced, graph-based language applications on top of large language models. Let me know if you need any other details on LangGraph and how it works!\n"
]
}
],
@@ -3068,9 +3061,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "langgraph",
"display_name": "env",
"language": "python",
"name": "langgraph"
"name": "python3"
},
"language_info": {
"codemirror_mode": {