mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
docs: small cleanup (#733)
This commit is contained in:
+21
-24
@@ -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 <strong>Re</strong>ason 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
|
||||
- [How to use a Pydantic model as your state](state-model.ipynb)
|
||||
- [How to extract structured output with re-prompting](./extraction/retries.ipynb)
|
||||
@@ -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
|
||||
- [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.
|
||||
+55
-57
@@ -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:
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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."
|
||||
]
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 @@
|
||||
"</div> "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0c3fde0a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7cbd446a-808f-4394-be92-d45ab818953c",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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/)."
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user