Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"What is LangGraph ?","local":"what-is-langgraph-","sections":[{"title":"Is LangGraph different from LangChain ?","local":"is-langgraph-different-from-langchain-","sections":[],"depth":2},{"title":"When should I use LangGraph ?","local":"when-should-i-use-langgraph-","sections":[{"title":"Control vs freedom","local":"control-vs-freedom","sections":[],"depth":3}],"depth":2},{"title":"How does LangGraph work?","local":"how-does-langgraph-work","sections":[],"depth":2},{"title":"How is it different from regular python? Why do I need LangGraph?","local":"how-is-it-different-from-regular-python-why-do-i-need-langgraph","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/agents-course/pr_545/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/entry/start.1596c81c.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/scheduler.37c15a92.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/singletons.8a3d92bd.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/index.18351ede.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/paths.5b2602e7.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/entry/app.856a784e.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/index.2bf4358c.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/nodes/0.1cd5790a.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/nodes/43.c4d8cc04.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/Heading.8ada512a.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/getInferenceSnippets.031140c2.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"What is LangGraph ?","local":"what-is-langgraph-","sections":[{"title":"Is LangGraph different from LangChain ?","local":"is-langgraph-different-from-langchain-","sections":[],"depth":2},{"title":"When should I use LangGraph ?","local":"when-should-i-use-langgraph-","sections":[{"title":"Control vs freedom","local":"control-vs-freedom","sections":[],"depth":3}],"depth":2},{"title":"How does LangGraph work?","local":"how-does-langgraph-work","sections":[],"depth":2},{"title":"How is it different from regular python? Why do I need LangGraph?","local":"how-is-it-different-from-regular-python-why-do-i-need-langgraph","sections":[],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h1 class="relative group"><a id="what-is-langgraph-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#what-is-langgraph-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>What is LangGraph ?</span></h1> <p data-svelte-h="svelte-rr2evv"><code>LangGraph</code> is a framework developed by <a href="https://www.langchain.com/" rel="nofollow">LangChain</a> <strong>to manage the control flow of applications that integrate an LLM</strong>.</p> <h2 class="relative group"><a id="is-langgraph-different-from-langchain-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#is-langgraph-different-from-langchain-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Is LangGraph different from LangChain ?</span></h2> <p data-svelte-h="svelte-6te0qc">LangChain provides a standard interface to interact with models and other components, useful for retrieval, LLM calls and tools calls. | |
| The classes from LangChain might be used in LangGraph, but do not HAVE to be used.</p> <p data-svelte-h="svelte-17r5ruq">The packages are different and can be used in isolation, but, in the end, all resources you will find online use both packages hand in hand.</p> <h2 class="relative group"><a id="when-should-i-use-langgraph-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#when-should-i-use-langgraph-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>When should I use LangGraph ?</span></h2> <h3 class="relative group"><a id="control-vs-freedom" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#control-vs-freedom"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Control vs freedom</span></h3> <p data-svelte-h="svelte-uqa85f">When designing AI applications, you face a fundamental trade-off between <strong>control</strong> and <strong>freedom</strong>:</p> <ul data-svelte-h="svelte-xtl0r5"><li><strong>Freedom</strong> gives your LLM more room to be creative and tackle unexpected problems.</li> <li><strong>Control</strong> allows you to ensure predictable behavior and maintain guardrails.</li></ul> <p data-svelte-h="svelte-8gs1cf">Code Agents, like the ones you can encounter in <em>smolagents</em>, are very free. They can call multiple tools in a single action step, create their own tools, etc. However, this behavior can make them less predictable and less controllable than a regular Agent working with JSON!</p> <p data-svelte-h="svelte-145e8a9"><code>LangGraph</code> is on the other end of the spectrum, it shines when you need <strong>“Control”</strong> on the execution of your agent.</p> <p data-svelte-h="svelte-1f44pjv">LangGraph is particularly valuable when you need <strong>Control over your applications</strong>. It gives you the tools to build an application that follows a predictable process while still leveraging the power of LLMs.</p> <p data-svelte-h="svelte-ci28iq">Put simply, if your application involves a series of steps that need to be orchestrated in a specific way, with decisions being made at each junction point, <strong>LangGraph provides the structure you need</strong>.</p> <p data-svelte-h="svelte-b1ur4q">As an example, let’s say we want to build an LLM assistant that can answer some questions over some documents.</p> <p data-svelte-h="svelte-n5n7zj">Since LLMs understand text the best, before being able to answer the question, you will need to convert other complex modalities (charts, tables) into text. However, that choice depends on the type of document you have!</p> <p data-svelte-h="svelte-jarhjf">This is a branching that I chose to represent as follow :</p> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/LangGraph/flow.png" alt="Control flow"> <blockquote data-svelte-h="svelte-5r1e3w"><p>💡 <strong>Tip:</strong> The left part is not an agent, as here no tool call is involved. but the right part will need to write some code to query the xls ( convert to pandas and manipulate it ).</p></blockquote> <p data-svelte-h="svelte-19pa7gi">While this branching is deterministic, you can also design branching that are conditioned on the output of an LLM making them undeterministic.</p> <p data-svelte-h="svelte-e2zi8a">The key scenarios where LangGraph excels include:</p> <ul data-svelte-h="svelte-19m02xj"><li><strong>Multi-step reasoning processes</strong> that need explicit control on the flow</li> <li><strong>Applications requiring persistence of state</strong> between steps</li> <li><strong>Systems that combine deterministic logic with AI capabilities</strong></li> <li><strong>Workflows that need human-in-the-loop interventions</strong></li> <li><strong>Complex agent architectures</strong> with multiple components working together</li></ul> <p data-svelte-h="svelte-ws59je">In essence, whenever possible, <strong>as a human</strong>, design a flow of actions based on the output of each action, and decide what to execute next accordingly. In this case, LangGraph is the correct framework for you!</p> <p data-svelte-h="svelte-sewitc"><code>LangGraph</code> is, in my opinion, the most production-ready agent framework on the market.</p> <h2 class="relative group"><a id="how-does-langgraph-work" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-does-langgraph-work"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>How does LangGraph work?</span></h2> <p data-svelte-h="svelte-socd2m">At its core, <code>LangGraph</code> uses a directed graph structure to define the flow of your application:</p> <ul data-svelte-h="svelte-90dzm2"><li><strong>Nodes</strong> represent individual processing steps (like calling an LLM, using a tool, or making a decision).</li> <li><strong>Edges</strong> define the possible transitions between steps.</li> <li><strong>State</strong> is user defined and maintained and passed between nodes during execution. When deciding which node to target next, this is the current state that we look at.</li></ul> <p data-svelte-h="svelte-oe0wtr">We will explore those fundamental blocks more in the next chapter!</p> <h2 class="relative group"><a id="how-is-it-different-from-regular-python-why-do-i-need-langgraph" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-is-it-different-from-regular-python-why-do-i-need-langgraph"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>How is it different from regular python? Why do I need LangGraph?</span></h2> <p data-svelte-h="svelte-15m7gka">You might wonder: “I could just write regular Python code with if-else statements to handle all these flows, right?”</p> <p data-svelte-h="svelte-15h78w9">While technically true, LangGraph offers <strong>some advantages</strong> over vanilla Python for building complex systems. You could build the same application without LangGraph, but it builds easier tools and abstractions for you.</p> <p data-svelte-h="svelte-12qxwd0">It includes states, visualization, logging (traces), built-in human-in-the-loop, and more.</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/agents-course/blob/main/units/en/unit2/langgraph/when_to_use_langgraph.mdx" target="_blank"><span data-svelte-h="svelte-1kd6by1"><</span> <span data-svelte-h="svelte-x0xyl0">></span> <span data-svelte-h="svelte-1dajgef"><span class="underline ml-1.5">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_17hovx6 = { | |
| assets: "/docs/agents-course/pr_545/en", | |
| base: "/docs/agents-course/pr_545/en", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/agents-course/pr_545/en/_app/immutable/entry/start.1596c81c.js"), | |
| import("/docs/agents-course/pr_545/en/_app/immutable/entry/app.856a784e.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 43], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 16.7 kB
- Xet hash:
- 397ab6e6b63aa0ebc4f3863a490de09638fa61ac00ade17e3bc0122ed78f3fc9
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.