diff --git a/docs/docs/how-tos/index.md b/docs/docs/how-tos/index.md index 234f1fcd2..8d64b2bda 100644 --- a/docs/docs/how-tos/index.md +++ b/docs/docs/how-tos/index.md @@ -4,37 +4,34 @@ Welcome to the LangGraph how-to guides! These guides provide practical, step-by- ## Core -The core guides show how to address common needs when building out AI workflows, with special focus placed on [ReAct](https://arxiv.org/abs/2210.03629)-style agents with [tool calling](https://python.langchain.com/docs/modules/model_io/chat/function_calling/). +The core guides show how to address common needs when building out AI workflows, with special focus placed on [ReAct](https://arxiv.org/abs/2210.03629)-style agents with [tool calling](https://python.langchain.com/docs/modules/model_io/chat/function_calling/) (agents that Reason and **Act** to accomplish tasks). -- [ReAct agent](create-react-agent.ipynb): How to create a tool-calling agent that **Re**asons and **Act**s to accomplish tasks -- [Persistence](persistence.ipynb): How to give your graph "memory" and resilience by saving and loading state -- [Time travel](time-travel.ipynb): How to navigate and manipulate graph state history once it's persisted -- [Async execution](async.ipynb): How to run nodes asynchronously for improved performance -- [Streaming responses](streaming-tokens.ipynb): How to stream agent responses in real-time -- [Visualization](visualization.ipynb): How to visualize your graphs -- [Configuration](configuration.ipynb): How to indicate that a graph can swap out configurable components +- [How to create a ReAct agent](create-react-agent.ipynb) +- [How to add persistence ("memory") to your graph](persistence.ipynb) +- [How to view and update graph state](time-travel.ipynb) +- [How to run graph asynchronously](async.ipynb) +- [How to stream graph responses](streaming-tokens.ipynb) +- [How to visualize your graph](visualization.ipynb) +- [How to add runtime configuration to your graph](configuration.ipynb) ### Design patterns Recipes showing how to apply common design patterns in your workflows: -- [Subgraphs](subgraph.ipynb): How to compose subgraphs within a larger graph -- [Branching](branching.ipynb): How to create branching logic in your graphs for parallel node execution -- [Map-reduce](map-reduce.ipynb): How to branch **different views** of the state for parallel node execution (even applying the same node in parallel N times) -- [Human-in-the-loop](human-in-the-loop.ipynb): How to incorporate human feedback and intervention +- [How to create subgraphs](subgraph.ipynb) +- [How to create branches for parallel execution](branching.ipynb) +- [How to create map-reduce branches for parallel execution](map-reduce.ipynb) +- [How to add human-in-the-loop](human-in-the-loop.ipynb) -The following examples are useful especially if you are used to LangChain's AgentExecutor configurations. +The following examples are useful especially if you are used to LangChain's `AgentExecutor` configurations. -- [Force calling a tool first](force-calling-a-tool-first.ipynb): Define a fixed workflow before ceding control to the ReAct agent -- [Pass run time values to tools](pass-run-time-values-to-tools.ipynb): Pass values that are only known at run time to tools (e.g., the ID of the user who made the request) -- [Dynamic direct return](dynamically-returning-directly.ipynb): Let the LLM decide whether the graph should finish after a tool is run or whether the LLM should be able to review the output and keep going -- [Respond in structured format](respond-in-format.ipynb): Let the LLM use tools or populate schema to provide the user. Useful if your agent should generate structured content -- [Managing agent steps](managing-agent-steps.ipynb): How to format the intermediate steps of your workflow for the agent +- [How to force an agent to call a tool](force-calling-a-tool-first.ipynb) +- [How to pass runtime values to tools](pass-run-time-values-to-tools.ipynb) +- [How to let agent return tool results directly](dynamically-returning-directly.ipynb) +- [How to have agent respond in structured format](respond-in-format.ipynb) +- [How to manage agent steps](managing-agent-steps.ipynb) -### Alternative ways to define state +### Advanced -- [Pydantic state](state-model.ipynb): Use a Pydantic model as your state - -### Structured output - -- [Extraction with re-prompting](./extraction/retries.ipynb): How to generate complex nested schemas using JSONPatch retries, for when function calling is insufficient, and regular reprompting still fails to generate valid results \ No newline at end of file +- [How to use a Pydantic model as your state](state-model.ipynb) +- [How to extract structured output with re-prompting](./extraction/retries.ipynb) \ No newline at end of file diff --git a/docs/docs/tutorials/index.md b/docs/docs/tutorials/index.md index 937575315..f7313f57f 100644 --- a/docs/docs/tutorials/index.md +++ b/docs/docs/tutorials/index.md @@ -15,55 +15,47 @@ Learn from example implementations of graphs designed for specific scenarios and #### Chatbots - [Customer Support](customer-support/customer-support.ipynb): Build a customer support chatbot to manage flights, hotel reservations, car rentals, and other tasks -- [Info Gathering](chatbots/information-gather-prompting.ipynb): Build an information gathering chatbot -- [Code Assistant](code_assistant/langgraph_code_assistant.ipynb): Building a code analysis and generation assistant - +- [Prompt Generation from User Requirements](chatbots/information-gather-prompting.ipynb): Build an information gathering chatbot +- [Code Assistant](code_assistant/langgraph_code_assistant.ipynb): Build a code analysis and generation assistant #### Multi-Agent Systems -- [Collaboration](multi_agent/multi-agent-collaboration.ipynb): Enabling two agents to collaborate on a task -- [Supervision](multi_agent/agent_supervisor.ipynb): Using an LLM to orchestrate and delegate to individual agents -- [Hierarchical Teams](multi_agent/hierarchical_agent_teams.ipynb): Orchestrating nested teams of agents to solve problems +- [Collaboration](multi_agent/multi-agent-collaboration.ipynb): Enable two agents to collaborate on a task +- [Supervision](multi_agent/agent_supervisor.ipynb): Use an LLM to orchestrate and delegate to individual agents +- [Hierarchical Teams](multi_agent/hierarchical_agent_teams.ipynb): Orchestrate nested teams of agents to solve problems #### RAG - [Adaptive RAG](rag/langgraph_adaptive_rag.ipynb) - - [Adaptive RAG using local models](rag/langgraph_adaptive_rag_local.ipynb) -- [Agentic RAG.ipynb](rag/langgraph_agentic_rag.ipynb) + - [Adaptive RAG using local LLMs](rag/langgraph_adaptive_rag_local.ipynb) +- [Agentic RAG](rag/langgraph_agentic_rag.ipynb) - [Corrective RAG](rag/langgraph_crag.ipynb) - - [Corrective RAG with local models](rag/langgraph_crag_local.ipynb) + - [Corrective RAG using local LLMs](rag/langgraph_crag_local.ipynb) - [Self-RAG](rag/langgraph_self_rag.ipynb) - - [Self-RAG with local models](rag/langgraph_self_rag_local.ipynb) -- [Web Research (STORM)](storm/storm.ipynb): Generating Wikipedia-like articles via research and multi-perspective QA - + - [Self-RAG using local LLMs](rag/langgraph_self_rag_local.ipynb) +- [SQL Agent](sql-agent.ipynb) #### Planning Agents -- [Plan-and-Execute](plan-and-execute/plan-and-execute.ipynb): Implementing a basic planning and execution agent -- [Reasoning without Observation](rewoo/rewoo.ipynb): Reducing re-planning by saving observations as variables -- [LLMCompiler](llm-compiler/LLMCompiler.ipynb): Streaming and eagerly executing a DAG of tasks from a planner +- [Plan-and-Execute](plan-and-execute/plan-and-execute.ipynb): Implement a basic planning and execution agent +- [Reasoning without Observation](rewoo/rewoo.ipynb): Reduce re-planning by saving observations as variables +- [LLMCompiler](llm-compiler/LLMCompiler.ipynb): Stream and eagerly execute a DAG of tasks from a planner #### Reflection & Critique -- [Basic Reflection](reflection/reflection.ipynb): Prompting the agent to reflect on and revise its outputs -- [Reflexion](reflexion/reflexion.ipynb): Critiquing missing and superfluous details to guide next steps -- [Language Agent Tree Search](lats/lats.ipynb): Using reflection and rewards to drive a tree search over agents -- [Self-Discovering Agent](self-discover/self-discover.ipynb): Analyzing an agent that learns about its own capabilities +- [Basic Reflection](reflection/reflection.ipynb): Prompt the agent to reflect on and revise its outputs +- [Reflexion](reflexion/reflexion.ipynb): Critique missing and superfluous details to guide next steps +- [Language Agent Tree Search](lats/lats.ipynb): Use reflection and rewards to drive a tree search over agents +- [Self-Discover Agent](self-discover/self-discover.ipynb): Analyze an agent that learns about its own capabilities #### Evaluation -- [Agent-based](chatbot-simulation-evaluation/agent-simulation-evaluation.ipynb): Evaluating chatbots via simulated user interactions -- [Within LangSmith](chatbot-simulation-evaluation/langsmith-agent-simulation-evaluation.ipynb): Evaluating chatbots in LangSmith over a dialog dataset +- [Agent-based](chatbot-simulation-evaluation/agent-simulation-evaluation.ipynb): Evaluate chatbots via simulated user interactions +- [In LangSmith](chatbot-simulation-evaluation/langsmith-agent-simulation-evaluation.ipynb): Evaluate chatbots in LangSmith over a dialog dataset -#### Text Mining +#### Experimental -- [TNT-LLM](tnt-llm/tnt-llm.ipynb): learn to build rich, interpretable taxonomies of user intentand using the classification system developed by Microsoft for their Bing Copilot application. - -#### Competitive Programming - -- [Can Language Models Solve Olympiad Programming?](usaco/usaco.ipynb): Build an agent with few-shot "episodic memory" and human-in-the-loop collaboration to solve problems from the USA Computing Olympiad; adapted from the [paper of the same name](https://arxiv.org/abs/2404.10952v1) by Shi, Tang, Narasimhan, and Yao. - - -#### Other Experimental Architectures - -- [Web Navigation](web-navigation/web_voyager.ipynb): Building an agent that can navigate and interact with websites \ No newline at end of file +- [Web Research (STORM)](storm/storm.ipynb): Generate Wikipedia-like articles via research and multi-perspective QA +- [TNT-LLM](tnt-llm/tnt-llm.ipynb): Build rich, interpretable taxonomies of user intentand using the classification system developed by Microsoft for their Bing Copilot application. +- [Web Navigation](web-navigation/web_voyager.ipynb): Build an agent that can navigate and interact with websites +- [Competitive Programming](usaco/usaco.ipynb): Build an agent with few-shot "episodic memory" and human-in-the-loop collaboration to solve problems from the USA Computing Olympiad; adapted from the ["Can Language Models Solve Olympiad Programming?"](https://arxiv.org/abs/2404.10952v1) paper by Shi, Tang, Narasimhan, and Yao. \ No newline at end of file diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 8276b0939..458bc7b96 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -26,7 +26,6 @@ theme: - navigation.instant.prefetch - navigation.instant.progress - navigation.prune - - navigation.sections - navigation.tabs - navigation.top - navigation.tracking @@ -97,67 +96,66 @@ nav: - Tutorials: - 'tutorials/index.md' - Introduction: tutorials/introduction.ipynb - - Use cases: - - Chatbots: - - Customer Support: tutorials/customer-support/customer-support.ipynb - - Info Gathering: tutorials/chatbots/information-gather-prompting.ipynb - - Code Assistant: tutorials/code_assistant/langgraph_code_assistant.ipynb - - Multi-Agent Systems: - - Collaboration: tutorials/multi_agent/multi-agent-collaboration.ipynb - - Supervision: tutorials/multi_agent/agent_supervisor.ipynb - - Hierarchical Teams: tutorials/multi_agent/hierarchical_agent_teams.ipynb - - RAG: - - tutorials/rag/langgraph_adaptive_rag.ipynb - - tutorials/rag/langgraph_adaptive_rag_local.ipynb - - tutorials/rag/langgraph_agentic_rag.ipynb - - tutorials/rag/langgraph_crag.ipynb - - tutorials/rag/langgraph_crag_local.ipynb - - tutorials/rag/langgraph_self_rag.ipynb - - tutorials/rag/langgraph_self_rag_local.ipynb - - Web Research (STORM): tutorials/storm/storm.ipynb - - Planning Agents: - - Plan-and-Execute: tutorials/plan-and-execute/plan-and-execute.ipynb - - Reasoning w/o Observation: tutorials/rewoo/rewoo.ipynb - - LLMCompiler: tutorials/llm-compiler/LLMCompiler.ipynb - - Reflection & Critique: - - Basic Reflection: tutorials/reflection/reflection.ipynb - - Reflexion: tutorials/reflexion/reflexion.ipynb - - Language Agent Tree Search: tutorials/lats/lats.ipynb - - Self-Discovering Agent: tutorials/self-discover/self-discover.ipynb - - Evaluation & Analysis: - - Chatbot Eval via Sim: - - Agent-based: tutorials/chatbot-simulation-evaluation/agent-simulation-evaluation.ipynb - - In LangSmith: tutorials/chatbot-simulation-evaluation/langsmith-agent-simulation-evaluation.ipynb - - Text Mining: - - TNT-LLM: tutorials/tnt-llm/tnt-llm.ipynb - - Web Navigation: tutorials/web-navigation/web_voyager.ipynb - - Competitive Programming: tutorials/usaco/usaco.ipynb - - SQL: tutorials/sql-agent.ipynb + - Chatbots: + - Customer Support: tutorials/customer-support/customer-support.ipynb + - Prompt Generation from User Requirements: tutorials/chatbots/information-gather-prompting.ipynb + - Code Assistant: tutorials/code_assistant/langgraph_code_assistant.ipynb + - RAG: + - Adaptive RAG: tutorials/rag/langgraph_adaptive_rag.ipynb + - Adaptive RAG using local LLMs: tutorials/rag/langgraph_adaptive_rag_local.ipynb + - Agentic RAG: tutorials/rag/langgraph_agentic_rag.ipynb + - Corrective RAG (CRAG): tutorials/rag/langgraph_crag.ipynb + - Corrective RAG (CRAG) using local LLMs: tutorials/rag/langgraph_crag_local.ipynb + - Self-RAG: tutorials/rag/langgraph_self_rag.ipynb + - Self-RAG using local LLMs: tutorials/rag/langgraph_self_rag_local.ipynb + - SQL Agent: tutorials/sql-agent.ipynb + - Agent Architectures: + - Multi-Agent Systems: + - Collaboration: tutorials/multi_agent/multi-agent-collaboration.ipynb + - Supervision: tutorials/multi_agent/agent_supervisor.ipynb + - Hierarchical Teams: tutorials/multi_agent/hierarchical_agent_teams.ipynb + - Planning Agents: + - Plan-and-Execute: tutorials/plan-and-execute/plan-and-execute.ipynb + - Reasoning without Observation: tutorials/rewoo/rewoo.ipynb + - LLMCompiler: tutorials/llm-compiler/LLMCompiler.ipynb + - Reflection & Critique: + - Basic Reflection: tutorials/reflection/reflection.ipynb + - Reflexion: tutorials/reflexion/reflexion.ipynb + - Language Agent Tree Search: tutorials/lats/lats.ipynb + - Self-Discover Agent: tutorials/self-discover/self-discover.ipynb + - Evaluation & Analysis: + - Chatbot Evaluation via Simulation: + - Agent-based: tutorials/chatbot-simulation-evaluation/agent-simulation-evaluation.ipynb + - In LangSmith: tutorials/chatbot-simulation-evaluation/langsmith-agent-simulation-evaluation.ipynb + - Experimental: + - Web Research (STORM): tutorials/storm/storm.ipynb + - TNT-LLM: tutorials/tnt-llm/tnt-llm.ipynb + - Web Navigation: tutorials/web-navigation/web_voyager.ipynb + - Competitive Programming: tutorials/usaco/usaco.ipynb - "How-to Guides": - 'how-tos/index.md' - Core: - - "ReAct Agent": how-tos/create-react-agent.ipynb - - "Persistence": how-tos/persistence.ipynb - - "Time Travel": how-tos/time-travel.ipynb - - "Async Execution": how-tos/async.ipynb - - "Streaming Responses": how-tos/streaming-tokens.ipynb - - "Visualization": how-tos/visualization.ipynb - - "Configuration": how-tos/configuration.ipynb + - Create a ReAct agent: how-tos/create-react-agent.ipynb + - Add persistence ("memory"): how-tos/persistence.ipynb + - View and update graph state: how-tos/time-travel.ipynb + - Run graph asynchronously: how-tos/async.ipynb + - Stream graph responses: how-tos/streaming-tokens.ipynb + - Visualize your graph: how-tos/visualization.ipynb + - Add runtime configuration: how-tos/configuration.ipynb - Design Patterns: - - "Subgraphs": how-tos/subgraph.ipynb - - "Branching": how-tos/branching.ipynb - - "Map-reduce": how-tos/map-reduce.ipynb - - "Human-in-the-Loop": how-tos/human-in-the-loop.ipynb - - "Force Calling a Tool First": how-tos/force-calling-a-tool-first.ipynb - - "Pass Run-Time Values to Tools": how-tos/pass-run-time-values-to-tools.ipynb - - "Dynamic Direct Return": how-tos/dynamically-returning-directly.ipynb - - "Respond in Structured Format": how-tos/respond-in-format.ipynb - - "Managing Agent Steps": how-tos/managing-agent-steps.ipynb - - Alternative State Definitions: - - "Pydantic State": how-tos/state-model.ipynb - - Structured Output: - - "Extraction with Re-prompting": how-tos/extraction/retries.ipynb + - Create subgraphs: how-tos/subgraph.ipynb + - Create branches for parallel execution: how-tos/branching.ipynb + - Create map-reduce branches for parallel execution: how-tos/map-reduce.ipynb + - Add human-in-the-loop: how-tos/human-in-the-loop.ipynb + - Force an agent to call a tool: how-tos/force-calling-a-tool-first.ipynb + - Pass runtime values to tools: how-tos/pass-run-time-values-to-tools.ipynb + - Let agent return tool results directly: how-tos/dynamically-returning-directly.ipynb + - Have agent respond in structured format: how-tos/respond-in-format.ipynb + - Manage agent steps: how-tos/managing-agent-steps.ipynb + - Advanced: + - Use Pydantic model as state: how-tos/state-model.ipynb + - Extract structured output with re-prompting: how-tos/extraction/retries.ipynb - 'Conceptual Guides': - 'concepts/index.md' - Reference: diff --git a/examples/async.ipynb b/examples/async.ipynb index 848c48cf6..dd77cbd9a 100644 --- a/examples/async.ipynb +++ b/examples/async.ipynb @@ -5,7 +5,7 @@ "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ - "# Async\n", + "# How to run graph asynchronously\n", "\n", "In this example we will build a ReAct agent with native [async](https://docs.python.org/3/library/asyncio.html) implementations of the core logic. When Chat Models have async clients, this can give us some nice performance improvements if you\n", "are running concurrent branches in your graph or if your graph is running within a larger web server process.\n", diff --git a/examples/branching.ipynb b/examples/branching.ipynb index 6b5a85256..f0fbe01c6 100644 --- a/examples/branching.ipynb +++ b/examples/branching.ipynb @@ -5,7 +5,7 @@ "id": "710dc4f0-1c88-4386-9e9d-fec3de6bb774", "metadata": {}, "source": [ - "# Branching\n", + "# How to create branches for parallel node execution\n", "\n", "LangGraph natively supports fan-out and fan-in using either regular edges or [conditional_edges](https://langchain-ai.github.io/langgraph/reference/graphs/#langgraph.graph.MessageGraph.add_conditional_edges).\n", "\n", diff --git a/examples/chatbots/information-gather-prompting.ipynb b/examples/chatbots/information-gather-prompting.ipynb index 7255b72f1..ddc4fb309 100644 --- a/examples/chatbots/information-gather-prompting.ipynb +++ b/examples/chatbots/information-gather-prompting.ipynb @@ -5,7 +5,7 @@ "id": "d72fae4e-f7de-42b7-91ee-bdd0a57ae46c", "metadata": {}, "source": [ - "# Prompt Generator\n", + "# Prompt Generation from User Requirements\n", "\n", "In this example we will create a chat bot that helps a user generate a prompt.\n", "It will first collect requirements from the user, and then will generate the prompt (and refine it based on user input).\n", diff --git a/examples/configuration.ipynb b/examples/configuration.ipynb index fb1bee442..c29269c01 100644 --- a/examples/configuration.ipynb +++ b/examples/configuration.ipynb @@ -5,7 +5,7 @@ "id": "6e6a0a39-9a4c-47ae-a238-1a3a847eea5b", "metadata": {}, "source": [ - "# Configuration\n", + "# How to add runtime configuration to your graph\n", "\n", "Sometimes you want to be able to configure your agent when calling it. \n", "Examples of this include configuring which LLM to use.\n", diff --git a/examples/dynamically-returning-directly.ipynb b/examples/dynamically-returning-directly.ipynb index 38b9e3b0e..0a55e4046 100644 --- a/examples/dynamically-returning-directly.ipynb +++ b/examples/dynamically-returning-directly.ipynb @@ -5,7 +5,7 @@ "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ - "# Dynamically Returning Directly\n", + "# How to let agent return tool results directly\n", "\n", "A typical ReAct loop follows user -> assistant -> tool -> assistant ..., -> user. In some cases, you don't need to call the LLM after the tool completes, the user can view the results directly themselves.\n", "\n", diff --git a/examples/extraction/retries.ipynb b/examples/extraction/retries.ipynb index 47de6529d..751997c40 100644 --- a/examples/extraction/retries.ipynb +++ b/examples/extraction/retries.ipynb @@ -5,7 +5,7 @@ "id": "e327e9bd-effc-4bee-a875-1c383c17f43d", "metadata": {}, "source": [ - "# Extraction with Re-prompting\n", + "# How to extract structured output with re-prompting\n", "\n", "Function calling is a core primitive for integrating LLMs within your software stack. We use it throughout the LangGraph docs, since developing with function calling (aka tool usage) tends to be much more stress-free than the traditional way of writing custom string parsers.\n", "\n", diff --git a/examples/force-calling-a-tool-first.ipynb b/examples/force-calling-a-tool-first.ipynb index 1c1947e1b..123829bf2 100644 --- a/examples/force-calling-a-tool-first.ipynb +++ b/examples/force-calling-a-tool-first.ipynb @@ -5,7 +5,7 @@ "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ - "# Force Calling a Tool First\n", + "# How to force an agent to call a tool\n", "\n", "In this example we will build a ReAct agent that **always** calls a certain tool first, before making any plans. In this example, we will create an agent with a search tool. However, at the start we will force the agent to call the search tool (and then let it do whatever it wants after). This is useful when you know you want to execute specific actions in your application but also want the flexibility of letting the LLM follow up on the user's query after going through that fixed sequence." ] diff --git a/examples/human-in-the-loop.ipynb b/examples/human-in-the-loop.ipynb index 1042d714f..1e4444402 100644 --- a/examples/human-in-the-loop.ipynb +++ b/examples/human-in-the-loop.ipynb @@ -5,9 +5,9 @@ "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ - "# Human-in-the-loop\n", + "# How to add human-in-the-loop\n", "\n", - "When creating LangGraph agents, it is often nice to add a human in the loop component.\n", + "When creating LangGraph agents, it is often nice to add a human-in-the-loop component.\n", "This can be helpful when giving them access to tools.\n", "Often in these situations you may want to manually approve an action before taking.\n", "\n", diff --git a/examples/managing-agent-steps.ipynb b/examples/managing-agent-steps.ipynb index 97c2abd05..670ed12c3 100644 --- a/examples/managing-agent-steps.ipynb +++ b/examples/managing-agent-steps.ipynb @@ -5,7 +5,7 @@ "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ - "# Managing Agent Steps\n", + "# How to manage agent steps\n", "\n", "In this example we will build a ReAct Agent that explicitly manages intermediate steps.\n", "\n", diff --git a/examples/map-reduce.ipynb b/examples/map-reduce.ipynb index eb9a254ef..f1d81c861 100644 --- a/examples/map-reduce.ipynb +++ b/examples/map-reduce.ipynb @@ -5,7 +5,7 @@ "id": "95a87145-34d0-4f97-b45f-5c9fd8532c8a", "metadata": {}, "source": [ - "# Map Reduce\n", + "# How to create map-reduce branches for parallel execution\n", "\n", "A common pattern in agents is to generate a list of objects, do some work on each of those objects, and then combine the results. This is very similar to the common [map-reduce](https://en.wikipedia.org/wiki/MapReduce) operation. This can be tricky for a few reasons. First, it can be tough to define a structured graph ahead of time because the length of the list of objects may be unknown. Second, in order to do this map-reduce you need multiple versions of the state to exist... but the graph shares a common shared state, so how can this be?\n", "\n", diff --git a/examples/pass-run-time-values-to-tools.ipynb b/examples/pass-run-time-values-to-tools.ipynb index ebeae58ef..8a39250c3 100644 --- a/examples/pass-run-time-values-to-tools.ipynb +++ b/examples/pass-run-time-values-to-tools.ipynb @@ -5,7 +5,7 @@ "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ - "# Passing run time values to tools\n", + "# How to pass runtime values to tools\n", "\n", "You may need to bind values to a tool that are only known at runtime. For example, the tool logic may require using the ID of the user who made the request.\n", "\n", diff --git a/examples/persistence.ipynb b/examples/persistence.ipynb index 32d7b2e5d..4977720bb 100644 --- a/examples/persistence.ipynb +++ b/examples/persistence.ipynb @@ -5,7 +5,7 @@ "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ - "# Persistence\n", + "# How to add persistence (\"memory\") to your graph\n", "\n", "Many AI applications need memory to share context across multiple interactions. In LangGraph, memory is provided for any [StateGraph](https://langchain-ai.github.io/langgraph/reference/graphs/#langgraph.graph.StateGraph) through [Checkpointers](https://langchain-ai.github.io/langgraph/reference/checkpoints/).\n", "\n", @@ -38,6 +38,14 @@ " " ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "0c3fde0a", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "id": "7cbd446a-808f-4394-be92-d45ab818953c", diff --git a/examples/rag/langgraph_adaptive_rag_local.ipynb b/examples/rag/langgraph_adaptive_rag_local.ipynb index ecf778a4f..28967c81c 100644 --- a/examples/rag/langgraph_adaptive_rag_local.ipynb +++ b/examples/rag/langgraph_adaptive_rag_local.ipynb @@ -10,7 +10,7 @@ "id": "bb89d3f0-7ade-43a8-a527-4bec45971cf6", "metadata": {}, "source": [ - "# Adaptive RAG -- With local LLMs\n", + "# Adaptive RAG using local LLMs\n", "\n", "Adaptive RAG is a strategy for RAG that unites (1) [query analysis](https://blog.langchain.dev/query-construction/) with (2) [active / self-corrective RAG](https://blog.langchain.dev/agentic-rag-with-langgraph/).\n", "\n", diff --git a/examples/rag/langgraph_agentic_rag.ipynb b/examples/rag/langgraph_agentic_rag.ipynb index 01049aa82..dfe7a0777 100644 --- a/examples/rag/langgraph_agentic_rag.ipynb +++ b/examples/rag/langgraph_agentic_rag.ipynb @@ -5,7 +5,7 @@ "id": "425fb020-e864-40ce-a31f-8da40c73d14b", "metadata": {}, "source": [ - "# LangGraph Retrieval Agent\n", + "# Agentic RAG\n", "\n", "[Retrieval Agents](https://python.langchain.com/v0.2/docs/tutorials/qa_chat_history/#agents) are useful when we want to make decisions about whether to retrieve from an index.\n", "\n", diff --git a/examples/rag/langgraph_crag_local.ipynb b/examples/rag/langgraph_crag_local.ipynb index 28f6e2ac5..48b68ab28 100644 --- a/examples/rag/langgraph_crag_local.ipynb +++ b/examples/rag/langgraph_crag_local.ipynb @@ -10,7 +10,7 @@ "id": "92ddc4f4-f7bf-4e0e-b5a5-5abd8a008b21", "metadata": {}, "source": [ - "# Corrective RAG (CRAG) -- With Local LLMs\n", + "# Corrective RAG (CRAG) using local LLMs\n", "\n", "Corrective-RAG (CRAG) is a strategy for RAG that incorporates self-reflection / self-grading on retrieved documents. \n", "\n", diff --git a/examples/rag/langgraph_self_rag.ipynb b/examples/rag/langgraph_self_rag.ipynb index 3f309a237..a28e50dfb 100644 --- a/examples/rag/langgraph_self_rag.ipynb +++ b/examples/rag/langgraph_self_rag.ipynb @@ -10,7 +10,7 @@ "id": "919fe33c-0149-4f7d-b200-544a18986c9a", "metadata": {}, "source": [ - "# Self RAG\n", + "# Self-RAG\n", "\n", "Self-RAG is a strategy for RAG that incorporates self-reflection / self-grading on retrieved documents and generations. \n", "\n", diff --git a/examples/rag/langgraph_self_rag_local.ipynb b/examples/rag/langgraph_self_rag_local.ipynb index 5ba7d8d57..a9855b07e 100644 --- a/examples/rag/langgraph_self_rag_local.ipynb +++ b/examples/rag/langgraph_self_rag_local.ipynb @@ -10,7 +10,7 @@ "id": "848ba742-7443-4123-8115-061da9823309", "metadata": {}, "source": [ - "# Self RAG -- With Local LLMs\n", + "# Self RAG usig local LLMs\n", "\n", "Self-RAG is a strategy for RAG that incorporates self-reflection / self-grading on retrieved documents and generations. \n", "\n", diff --git a/examples/self-discover/self-discover.ipynb b/examples/self-discover/self-discover.ipynb index f626c0d34..9c4dbfeef 100644 --- a/examples/self-discover/self-discover.ipynb +++ b/examples/self-discover/self-discover.ipynb @@ -5,7 +5,7 @@ "id": "a38e5d2d-7587-4192-90f2-b58e6c62f08c", "metadata": {}, "source": [ - "# Self Discover\n", + "# Self-Discover Agent\n", "\n", "An implementation of the [Self-Discover paper](https://arxiv.org/pdf/2402.03620.pdf).\n", "\n", diff --git a/examples/state-model.ipynb b/examples/state-model.ipynb index 5a1bca9fe..e264e269d 100644 --- a/examples/state-model.ipynb +++ b/examples/state-model.ipynb @@ -5,7 +5,7 @@ "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ - "# Pydantic Base Model as State\n", + "# How to use Pydantic model as state\n", "\n", "Every [StateGraph](https://langchain-ai.github.io/langgraph/reference/graphs/#langgraph.graph.StateGraph) is a state machine. When initializing, it accepts a `state_schema` that tells it the \"shape\" of its state and how to incorporate updates from the nodes into a shared representation of what work has been done.\n", "\n", diff --git a/examples/storm/storm.ipynb b/examples/storm/storm.ipynb index 5d99703bb..f27649bfa 100644 --- a/examples/storm/storm.ipynb +++ b/examples/storm/storm.ipynb @@ -9,7 +9,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# STORM\n", + "# Web Research (STORM)\n", "\n", "[STORM](https://arxiv.org/abs/2402.14207) is a research assistant designed by Shao, et. al that extends the idea of \"outline-driven RAG\" for richer article generation.\n", "\n", diff --git a/examples/streaming-tokens.ipynb b/examples/streaming-tokens.ipynb index 28e786648..62632c132 100644 --- a/examples/streaming-tokens.ipynb +++ b/examples/streaming-tokens.ipynb @@ -5,7 +5,7 @@ "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ - "# Streaming Tokens\n", + "# How to stream graph responses\n", "\n", "In this example we will stream tokens from the language model powering an agent. We will use a ReAct agent as an example. The main thing to bear in mind here is that using [async nodes](./async.ipynb) typically offers the best behavior for this, since we will be using the `astream_events` method.\n", "\n", diff --git a/examples/subgraph.ipynb b/examples/subgraph.ipynb index 8df91b956..f92d59733 100644 --- a/examples/subgraph.ipynb +++ b/examples/subgraph.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Subgraphs\n", + "# How to create subgraphs\n", "\n", "Graphs such as [StateGraph](https://langchain-ai.github.io/langgraph/reference/graphs/#langgraph.graph.StateGraph)'s naturally can be composed. Creating subgraphs lets you build things like [multi-agent teams](./multi_agent/hierarchical_agent_teams.ipynb), where each team can track its own separate state.\n", "\n", diff --git a/examples/time-travel.ipynb b/examples/time-travel.ipynb index 598623a9e..b782cec30 100644 --- a/examples/time-travel.ipynb +++ b/examples/time-travel.ipynb @@ -5,7 +5,7 @@ "id": "51466c8d-8ce4-4b3d-be4e-18fdbeda5f53", "metadata": {}, "source": [ - "# Get/Update State\n", + "# How to view and update graph state\n", "\n", "Once you start [checkpointing](./persistence.ipynb) your graphs, you can easily **get** or **update** the state of the agent at any point in time. This permits a few things:\n", "\n", diff --git a/examples/tutorials/sql-agent.ipynb b/examples/tutorials/sql-agent.ipynb index c59e5071a..50590f6da 100644 --- a/examples/tutorials/sql-agent.ipynb +++ b/examples/tutorials/sql-agent.ipynb @@ -165,7 +165,7 @@ "outputs": [], "source": [ "%%capture --no-stderr --no-display\n", - "!pip install langchain_community langchain_openai" + "!pip install langgraph langchain_community langchain_openai" ] }, { @@ -246,6 +246,7 @@ "\n", "from langchain_core.messages import ToolMessage\n", "from langchain_core.runnables import RunnableLambda, RunnableWithFallbacks\n", + "from langgraph.prebuilt import ToolNode\n", "\n", "\n", "def create_tool_node_with_fallback(tools: list) -> RunnableWithFallbacks[Any, dict]:\n", @@ -380,7 +381,7 @@ } ], "source": [ - "from langchain.agents import tool\n", + "from langchain_core.tools import tool\n", "\n", "\n", "@tool\n", @@ -501,7 +502,6 @@ "\n", "from langgraph.graph import END, StateGraph\n", "from langgraph.graph.message import AnyMessage, add_messages\n", - "from langgraph.prebuilt.tool_node import ToolNode\n", "\n", "\n", "# Define the state for the agent\n", diff --git a/examples/usaco/usaco.ipynb b/examples/usaco/usaco.ipynb index f647abc3c..7abeb566c 100644 --- a/examples/usaco/usaco.ipynb +++ b/examples/usaco/usaco.ipynb @@ -5,7 +5,7 @@ "id": "69ad077f-af4e-49b8-b549-fb3112299aa8", "metadata": {}, "source": [ - "# Can Language Models Solve Olympiad Programming?\n", + "# Competitive Programming\n", "\n", "In this tutorial, you will build a computing olympiad agent that leverages three complementary techniques to boost performance: **reflection**, **retrieval**, and **human-in-the-loop** collaboration. These techniques and data are all adapted from the paper \"Can Language Models Solve Olympiad Programming?\" by Quan Shi, Michael Tang, Karthik Narasimhan, and Shunyu Yao. You can check out their paper at the following link:\n", "\n", diff --git a/examples/visualization.ipynb b/examples/visualization.ipynb index 2c8ae3853..8d0e2f14f 100644 --- a/examples/visualization.ipynb +++ b/examples/visualization.ipynb @@ -5,7 +5,7 @@ "id": "8bcd1a3d-7c50-4f58-be4e-1ed654aa33be", "metadata": {}, "source": [ - "# Visualization\n", + "# How to visualize your graph\n", "\n", "This notebook walks through how to visualize the graphs you create. This works with ANY [Graph](https://langchain-ai.github.io/langgraph/reference/graphs/)." ]