mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 22:14:11 +08:00
66 lines
15 KiB
HTML
66 lines
15 KiB
HTML
<!doctype html>
|
||
<html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-components/chains" data-has-hydrated="false">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="generator" content="Docusaurus v3.4.0">
|
||
<title data-rh="true">Chains | Langflow Documentation</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://langflow-ai.github.io/components/chains"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Chains | Langflow Documentation"><meta data-rh="true" name="description" content="This page may contain outdated information. It will be updated as soon as possible."><meta data-rh="true" property="og:description" content="This page may contain outdated information. It will be updated as soon as possible."><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://langflow-ai.github.io/components/chains"><link data-rh="true" rel="alternate" href="https://langflow-ai.github.io/components/chains" hreflang="en"><link data-rh="true" rel="alternate" href="https://langflow-ai.github.io/components/chains" hreflang="x-default"><link rel="preconnect" href="https://www.google-analytics.com">
|
||
<link rel="preconnect" href="https://www.googletagmanager.com">
|
||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XHC7G628ZP"></script>
|
||
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-XHC7G628ZP",{anonymize_ip:!0})</script><link rel="stylesheet" href="/assets/css/styles.9e9b53af.css">
|
||
<script src="/assets/js/runtime~main.419a4058.js" defer="defer"></script>
|
||
<script src="/assets/js/main.0598702c.js" defer="defer"></script>
|
||
</head>
|
||
<body class="navigation-with-keyboard">
|
||
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme")}catch(t){}}();null!==e?t(e):window.matchMedia("(prefers-color-scheme: dark)").matches?t("dark"):(window.matchMedia("(prefers-color-scheme: light)").matches,t("light"))}(),function(){try{const c=new URLSearchParams(window.location.search).entries();for(var[t,e]of c)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top navbarHideable_m1mJ"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/chain.png" alt="Langflow" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="/img/chain.png" alt="Langflow" class="themedComponent_mlkZ themedComponent--dark_xIcU"></div><b class="navbar__title text--truncate">Langflow</b></a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/langflow-ai/langflow" target="_blank" class="navbar__item navbar__link header-github-link"></a><a href="https://twitter.com/langflow_ai" target="_blank" class="navbar__item navbar__link header-twitter-link"></a><a href="https://discord.gg/EqksyE2EX9" target="_blank" class="navbar__item navbar__link header-discord-link"></a><div class="toggle_vylO colorModeToggle_DEke"><button class="clean-btn toggleButton_gllP toggleButtonDisabled_aARS" type="button" disabled="" title="Switch between dark and light mode (currently light mode)" aria-label="Switch between dark and light mode (currently light mode)" aria-live="polite"><svg viewBox="0 0 24 24" width="24" height="24" class="lightToggleIcon_pyhR"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg><svg viewBox="0 0 24 24" width="24" height="24" class="darkToggleIcon_wfgR"><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg></button></div><div class="navbarSearchContainer_Bca1"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0"><div class="docsWrapper_hBAB"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docRoot_UBD9"><main class="docMainContainer_TBSr docMainContainerEnhanced_lQrH"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><h1>Chains</h1>
|
||
<div class="theme-admonition theme-admonition-warning admonition_xJq3 alert alert--warning"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg></span>warning</div><div class="admonitionContent_BuS1"><p>This page may contain outdated information. It will be updated as soon as possible.</p></div></div>
|
||
<p>Chains, in the context of language models, refer to a series of calls made to a language model. This approach allows for using the output of one call as the input for another. Different chain types facilitate varying complexity levels, making them useful for creating pipelines and executing specific scenarios.</p>
|
||
<hr>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="combinedocschain">CombineDocsChain<a class="hash-link" aria-label="Direct link to CombineDocsChain" title="Direct link to CombineDocsChain" href="/components/chains#combinedocschain"></a></h2>
|
||
<p><code>CombineDocsChain</code> includes methods to combine or aggregate loaded documents for question-answering functionality.</p>
|
||
<p>Acts as a proxy for LangChain’s <a href="https://python.langchain.com/docs/modules/chains/document/" target="_blank" rel="noopener noreferrer">documents</a> chains produced by the <code>load_qa_chain</code> function.</p>
|
||
<p><strong>Parameters</strong>:</p>
|
||
<ul>
|
||
<li><strong>LLM:</strong> Language Model to use in the chain.</li>
|
||
<li><strong>chain_type:</strong> Type of chain to be used, each applying a different combination strategy:<!-- -->
|
||
<ul>
|
||
<li><strong>stuff</strong>: Most straightforward document chain. It takes a list of documents, inserts them all into a prompt, and passes that prompt to an LLM. Suitable for cases where documents are small and few.</li>
|
||
<li><strong>map_reduce</strong>: Applies an LLM to each document individually (the <code>Map</code> step), treating the output as a new document. It then combines these documents to get a single output (the <code>Reduce</code> step). Compression may occur to ensure documents fit in the final chain.</li>
|
||
<li><strong>map_rerank</strong>: Runs an initial prompt on each document to complete a task and score its certainty. Returns the highest-scoring response.</li>
|
||
<li><strong>refine</strong>: Iteratively updates its answer by looping over the input documents. Each document, along with the latest intermediate answer, is passed to an LLM to generate a new response. This method suits tasks requiring analysis of more documents than the model's context can handle, though it can be less effective for tasks requiring detailed cross-referencing or comprehensive information.</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<hr>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="conversationchain">ConversationChain<a class="hash-link" aria-label="Direct link to ConversationChain" title="Direct link to ConversationChain" href="/components/chains#conversationchain"></a></h2>
|
||
<p><code>ConversationChain</code> facilitates dynamic, interactive conversations with a language model, ideal for chatbots or virtual assistants.</p>
|
||
<p><strong>Parameters</strong>:</p>
|
||
<ul>
|
||
<li><strong>LLM:</strong> Language Model to use in the chain.</li>
|
||
<li><strong>Memory:</strong> Default memory store.</li>
|
||
<li><strong>input_key:</strong> Specifies the key under which user input is stored in the conversation memory, enabling the chain to process and generate responses.</li>
|
||
<li><strong>output_key:</strong> Specifies the key under which the generated response is stored, allowing retrieval of the response using this key.</li>
|
||
<li><strong>verbose:</strong> Controls the verbosity of the chain's output. Set to <code>True</code> to enable detailed internal state outputs, useful for debugging and understanding the chain's behavior. Defaults to <code>False</code>.</li>
|
||
</ul>
|
||
<hr>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="conversationalretrievalchain">ConversationalRetrievalChain<a class="hash-link" aria-label="Direct link to ConversationalRetrievalChain" title="Direct link to ConversationalRetrievalChain" href="/components/chains#conversationalretrievalchain"></a></h2>
|
||
<p><code>ConversationalRetrievalChain</code> combines document search with question-answering capabilities, extracting information and providing answers.</p>
|
||
<p>A retriever finds documents based on a query but doesn’t store them; it returns the documents matching the query.</p>
|
||
<p><strong>Parameters</strong>:</p>
|
||
<ul>
|
||
<li><strong>LLM:</strong> Language Model to use in the chain.</li>
|
||
<li><strong>Memory:</strong> Default memory store.</li>
|
||
<li><strong>Retriever:</strong> The retriever used to fetch relevant documents.</li>
|
||
<li><strong>chain_type:</strong> Type of chain to be used, each applying a different combination strategy:<!-- -->
|
||
<ul>
|
||
<li><strong>stuff</strong>: Inserts a list of documents into a prompt and passes it to an LLM. Suitable for cases where documents are small and few.</li>
|
||
<li><strong>map_reduce</strong>: Processes each document with an LLM separately, combines them for a single output. Compressions may occur to fit documents into the final chain.</li>
|
||
<li><strong>map_rerank</strong>: Scores responses based on certainty from each document, returns the highest.</li>
|
||
<li><strong>refine</strong>: Updates answers iteratively by looping through documents, passing each with intermediate answers to an LLM for a new response. This method is beneficial for tasks that involve extensive document analysis.</li>
|
||
</ul>
|
||
</li>
|
||
<li><strong>return_source_documents:</strong> Specifies whether to include source documents used in the output. Useful for providing context or references to the user. Defaults to <code>True</code>.</li>
|
||
<li><strong>verbose:</strong> Controls verbosity of output. Set to <code>True</code> for detailed logs, useful for debugging. Defaults to <code>False</code>.</li>
|
||
</ul>
|
||
<hr></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a class="table-of-contents__link toc-highlight" href="/components/chains#combinedocschain">CombineDocsChain</a></li><li><a class="table-of-contents__link toc-highlight" href="/components/chains#conversationchain">ConversationChain</a></li><li><a class="table-of-contents__link toc-highlight" href="/components/chains#conversationalretrievalchain">ConversationalRetrievalChain</a></li></ul></div></div></div></div></main></div></div></div><div class="ms-fixed ms-bottom-4 ms-right-8 ms-z-[100] ms-flex ms-flex-col ms-items-end hover:ms-cursor-pointer"><div class="ms-relative ms-mb-4"><div style="background-color:#f6f6f6" class="ms-absolute -ms-bottom-1 ms-right-6 -ms-z-10 ms-h-4 ms-w-4 ms-rotate-45"></div><div style="background-color:#f6f6f6" class="ms-z-10 ms-flex ms-items-center ms-justify-center ms-rounded-lg ms-px-3 ms-py-2"><p style="color:#000000;margin:0" class="ms-text-sm">Hi, how can I help you?</p></div></div><div style="background-color:#f6f6f6" class="ms-flex ms-h-16 ms-w-16 ms-flex-col ms-items-center ms-justify-center ms-self-end ms-rounded-full ms-p-2 ms-transition"><div class="ms-rotate-0 ms-flex ms-h-full ms-w-full ms-transform ms-cursor-pointer ms-items-center ms-justify-center ms-rounded-full ms-transition-all ms-delay-75 ms-duration-100 ms-ease-in-out"><div style="color:#000000;font-size:22px;width:48px;height:48px;margin:0px;padding:0px;display:flex;align-items:center;justify-content:center;text-align:center"><img src="/img/chain.png" style="width:40px"></div></div></div><div></div></div></div>
|
||
</body>
|
||
</html> |