mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 03:21:47 +08:00
95 lines
41 KiB
HTML
95 lines
41 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-Concepts/concepts-api" data-has-hydrated="false">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="generator" content="Docusaurus v3.7.0">
|
||
<title data-rh="true">API pane | 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://docs.langflow.org/concepts-api"><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="API pane | Langflow Documentation"><meta data-rh="true" name="description" content="The API pane presents code templates for integrating your flow into external applications."><meta data-rh="true" property="og:description" content="The API pane presents code templates for integrating your flow into external applications."><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://docs.langflow.org/concepts-api"><link data-rh="true" rel="alternate" href="https://docs.langflow.org/concepts-api" hreflang="en"><link data-rh="true" rel="alternate" href="https://docs.langflow.org/concepts-api" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://UZK6BDPCVY-dsn.algolia.net" crossorigin="anonymous"><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="preconnect" href="https://www.googletagmanager.com">
|
||
<script>window.dataLayer=window.dataLayer||[]</script>
|
||
<script>!function(e,t,a,n){e[n]=e[n]||[],e[n].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var g=t.getElementsByTagName(a)[0],m=t.createElement(a);m.async=!0,m.src="https://www.googletagmanager.com/gtm.js?id=GTM-NK5M4ZT8",g.parentNode.insertBefore(m,g)}(window,document,"script","dataLayer")</script>
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml" title="Langflow Documentation" href="/opensearch.xml"><link rel="stylesheet" href="/assets/css/styles.e5a88218.css">
|
||
<script src="/assets/js/runtime~main.22d1d3f1.js" defer="defer"></script>
|
||
<script src="/assets/js/main.950e95c5.js" defer="defer"></script>
|
||
</head>
|
||
<body class="navigation-with-keyboard">
|
||
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NK5M4ZT8" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
||
|
||
|
||
|
||
|
||
<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/langflow-logo-black.svg" alt="Langflow" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="/img/langflow-logo-white.svg" alt="Langflow" class="themedComponent_mlkZ themedComponent--dark_xIcU"></div></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" aria-pressed="false"><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"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search (Command+K)"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"></span></button></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"><aside class="theme-doc-sidebar-container docSidebarContainer_YfHR"><div class="sidebarViewport_aRkj"><div class="sidebar_njMd sidebarWithHideableNavbar_wUlq"><a tabindex="-1" class="sidebarLogo_isFc" href="/"><img src="/img/langflow-logo-black.svg" alt="Langflow" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="/img/langflow-logo-white.svg" alt="Langflow" class="themedComponent_mlkZ themedComponent--dark_xIcU"></a><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/">Welcome to Langflow</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/get-started-installation">Get started</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/starter-projects-basic-prompting">Starter projects</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/tutorials-blog-writer">Tutorials</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" role="button" aria-expanded="true" href="/concepts-overview">Concepts</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/concepts-overview">Langflow overview</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/concepts-playground">Playground</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/concepts-components">Components</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/Concepts/concepts-flows">Flows</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/concepts-objects">Langflow objects</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/concepts-api">API pane</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/components-agents">Components</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/agents-overview">Agents</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/configuration-api-keys">Configuration</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/deployment-docker">Deployment</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/api">API reference</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/integrations-apify">Integrations</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/contributing-community">Contributing</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a href="https://github.com/langflow-ai/langflow/releases/latest" target="_blank" rel="noopener noreferrer" class="menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false">Changelog</a></div></li></ul></nav></div></div></aside><main class="docMainContainer_TBSr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_YNFT"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Concepts</span><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">API pane</span><meta itemprop="position" content="2"></li></ul></nav><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"><header><h1>API pane</h1></header><style>[data-ch-theme="github-dark"] { --ch-t-colorScheme: dark;--ch-t-foreground: #c9d1d9;--ch-t-background: #0d1117;--ch-t-lighter-inlineBackground: #0d1117e6;--ch-t-editor-background: #0d1117;--ch-t-editor-foreground: #c9d1d9;--ch-t-editor-lineHighlightBackground: #6e76811a;--ch-t-editor-rangeHighlightBackground: #ffffff0b;--ch-t-editor-infoForeground: #3794FF;--ch-t-editor-selectionBackground: #264F78;--ch-t-focusBorder: #1f6feb;--ch-t-tab-activeBackground: #0d1117;--ch-t-tab-activeForeground: #c9d1d9;--ch-t-tab-inactiveBackground: #010409;--ch-t-tab-inactiveForeground: #8b949e;--ch-t-tab-border: #30363d;--ch-t-tab-activeBorder: #0d1117;--ch-t-editorGroup-border: #30363d;--ch-t-editorGroupHeader-tabsBackground: #010409;--ch-t-editorLineNumber-foreground: #6e7681;--ch-t-input-background: #0d1117;--ch-t-input-foreground: #c9d1d9;--ch-t-input-border: #30363d;--ch-t-icon-foreground: #8b949e;--ch-t-sideBar-background: #010409;--ch-t-sideBar-foreground: #c9d1d9;--ch-t-sideBar-border: #30363d;--ch-t-list-activeSelectionBackground: #6e768166;--ch-t-list-activeSelectionForeground: #c9d1d9;--ch-t-list-hoverBackground: #6e76811a;--ch-t-list-hoverForeground: #c9d1d9; }</style>
|
||
<!-- -->
|
||
<p>The <strong>API</strong> pane presents code templates for integrating your flow into external applications.</p>
|
||
<p><img decoding="async" loading="lazy" src="/assets/images/api-pane-97a01b20a262676d4e21906df0e29f46.png" width="3236" height="1760" class="img_ev3q"></p>
|
||
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">curl</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Python API</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">JS API</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Python code</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><p>The <strong>cURL</strong> tab displays sample code for posting a query to your flow. Modify the <code>input_value</code> to change your input message. Copy the code and run it to post a query to your flow and get the result.</p></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Python API</strong> tab displays code to interact with your flow using the Python HTTP <code>requests</code> library.</p><p>To use the <code>requests</code> library:</p><ol>
|
||
<li>Copy and paste the code into a Python script.</li>
|
||
<li>Run the script and pass your message with it.</li>
|
||
</ol><div class="ch-codeblock not-prose" data-ch-theme="github-dark"><div class="ch-code-wrapper ch-code" data-ch-measured="false"><code class="ch-code-scroll-parent"><br><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>python3 python-test-script.py --message="tell me about something interesting"</span></div></div><br></code></div></div></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>JavaScript API</strong> tab displays code to interact with your flow in JavaScript.</p><ol>
|
||
<li>Copy and paste the code into a JavaScript file.</li>
|
||
<li>Run the script with any necessary arguments for your flow:</li>
|
||
</ol><div class="ch-codeblock not-prose" data-ch-theme="github-dark"><div class="ch-code-wrapper ch-code" data-ch-measured="false"><code class="ch-code-scroll-parent"><br><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>node test-script.js "tell me about something interesting"</span></div></div><br></code></div></div><p>The response content depends on your flow. Make sure the endpoint returns a successful response.</p></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Python Code</strong> tab displays code to interact with your flow's <code>.json</code> file using the Langflow runtime.</p><p>To use your code in a Python application using the Langflow runtime, you have to first download your flow’s JSON file.</p><ol>
|
||
<li>
|
||
<p>In your <strong>Workspace</strong>, click <strong>Settings</strong>, and then select <strong>Export</strong>.</p>
|
||
</li>
|
||
<li>
|
||
<p>Download the flow to your local machine. Make sure the flow path in the script matches the flow’s location on your machine.</p>
|
||
</li>
|
||
<li>
|
||
<p>Copy and paste the code from the <strong>Python Code</strong> tab into a Python script file.</p>
|
||
</li>
|
||
<li>
|
||
<p>Run the script:</p>
|
||
</li>
|
||
</ol><div class="ch-codeblock not-prose" data-ch-theme="github-dark"><div class="ch-code-wrapper ch-code" data-ch-measured="false"><code class="ch-code-scroll-parent"><br><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>python python-test-script.py</span></div></div><br></code></div></div></div></div></div>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="chat-widget">Chat Widget<a href="#chat-widget" class="hash-link" aria-label="Direct link to Chat Widget" title="Direct link to Chat Widget"></a></h2>
|
||
<p>The <strong>Chat Widget HTML</strong> tab displays code that can be inserted in the <code><body></code> of your HTML to interact with your flow.</p>
|
||
<p>The <strong>Langflow Chat Widget</strong> is a powerful web component that enables communication with a Langflow project. This widget allows for a chat interface embedding, allowing the integration of Langflow into web applications effortlessly.</p>
|
||
<p>You can get the HTML code embedded with the chat by clicking the Code button at the Sidebar after building a flow.</p>
|
||
<p>Clicking the Chat Widget HTML tab, you'll get the code to be inserted. Read below to learn how to use it with HTML, React and Angular.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="embed-the-chat-widget-into-html">Embed the chat widget into HTML<a href="#embed-the-chat-widget-into-html" class="hash-link" aria-label="Direct link to Embed the chat widget into HTML" title="Direct link to Embed the chat widget into HTML"></a></h3>
|
||
<p>To embed the chat widget into any HTML page, insert the code snippet. inside a <code><body></code> tag.</p>
|
||
<div class="ch-codeblock not-prose" data-ch-theme="github-dark"><div class="ch-code-wrapper ch-code" data-ch-measured="false"><code class="ch-code-scroll-parent"><br><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span><script src="https://cdn.jsdelivr.net/gh/logspace-ai/langflow-embedded-chat@v1.0.7/dist/build/static/js/bundle.min.js""></script></span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span></span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> <langflow-chat</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> window_title="Basic Prompting"</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> flow_id="801abb1e-19b9-4278-9632-179b6d84f126"</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> host_url="http://localhost:7860"</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span></span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> ></langflow-chat></span></div></div><br></code></div></div>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="embed-the-chat-widget-with-react">Embed the chat widget with React<a href="#embed-the-chat-widget-with-react" class="hash-link" aria-label="Direct link to Embed the chat widget with React" title="Direct link to Embed the chat widget with React"></a></h3>
|
||
<p>To embed the Chat Widget using React, insert this <code><script></code> tag into the React <em>index.html</em> file, inside the <code><body></code>tag:</p>
|
||
<div class="ch-codeblock not-prose" data-ch-theme="github-dark"><div class="ch-code-wrapper ch-code" data-ch-measured="false"><code class="ch-code-scroll-parent"><br><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span><script src="https://cdn.jsdelivr.net/gh/langflow-ai/langflow-embedded-chat@main/dist/build/static/js/bundle.min.js"></script></span></div></div><br></code></div></div>
|
||
<p>Declare your Web Component and encapsulate it in a React component.</p>
|
||
<div class="ch-codeblock not-prose" data-ch-theme="github-dark"><div class="ch-code-wrapper ch-code" data-ch-measured="false"><code class="ch-code-scroll-parent"><br><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span>declare global {</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> namespace JSX {</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> interface IntrinsicElements {</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> "langflow-chat": any;</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> }</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> }</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span>}</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span></span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span>export default function ChatWidget({ className }) {</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> return (</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> <div className={className}></span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> <langflow-chat</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> chat_inputs='{"your_key":"value"}'</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> chat_input_field="your_chat_key"</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> flow_id="your_flow_id"</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> host_url="langflow_url"</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> ></langflow-chat></span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> </div></span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span> );</span></div></div><div><span class="ch-code-line-number">_<!-- -->20</span><div style="display:inline-block;margin-left:16px"><span>}</span></div></div><br></code></div></div>
|
||
<p>Place the component anywhere in your code to display the Chat Widget.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="embed-the-chat-widget-with-angular">Embed the chat widget with Angular<a href="#embed-the-chat-widget-with-angular" class="hash-link" aria-label="Direct link to Embed the chat widget with Angular" title="Direct link to Embed the chat widget with Angular"></a></h3>
|
||
<p>To use the chat widget in Angular, first add this <code><script></code> tag into the Angular <em>index.html</em> file, inside the <code><body></code> tag.</p>
|
||
<div class="ch-codeblock not-prose" data-ch-theme="github-dark"><div class="ch-code-wrapper ch-code" data-ch-measured="false"><code class="ch-code-scroll-parent"><br><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span><script src="https://cdn.jsdelivr.net/gh/langflow-ai/langflow-embedded-chat@main/dist/build/static/js/bundle.min.js"></script></span></div></div><br></code></div></div>
|
||
<p>When you use a custom web component in an Angular template, the Angular compiler might show a warning when it doesn't recognize the custom elements by default. To suppress this warning, add <code>CUSTOM_ELEMENTS_SCHEMA</code> to the module's <code>@NgModule.schemas</code>.</p>
|
||
<ul>
|
||
<li>Open the module file (it typically ends with <em>.module.ts</em>) where you'd add the <code>langflow-chat</code> web component.</li>
|
||
<li>Import <code>CUSTOM_ELEMENTS_SCHEMA</code> at the top of the file:</li>
|
||
</ul>
|
||
<p><code>import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';</code></p>
|
||
<ul>
|
||
<li>Add <code>CUSTOM_ELEMENTS_SCHEMA</code> to the 'schemas' array inside the '@NgModule' decorator:</li>
|
||
</ul>
|
||
<div class="ch-codeblock not-prose" data-ch-theme="github-dark"><div class="ch-code-wrapper ch-code" data-ch-measured="false"><code class="ch-code-scroll-parent"><br><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span>@NgModule({</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> declarations: [</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> // ... Other components and directives ...</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> ],</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> imports: [</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> // ... Other imported modules ...</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> ],</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> schemas: [</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> CUSTOM_ELEMENTS_SCHEMA // Add the CUSTOM_ELEMENTS_SCHEMA here</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> ]</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span>})</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span>export class YourModule { }</span></div></div><br></code></div></div>
|
||
<p>In your Angular project, find the component belonging to the module where <code>CUSTOM_ELEMENTS_SCHEMA</code> was added. Inside the template, add the <code>langflow-chat</code> tag to include the Chat Widget in your component's view:</p>
|
||
<div class="ch-codeblock not-prose" data-ch-theme="github-dark"><div class="ch-code-wrapper ch-code" data-ch-measured="false"><code class="ch-code-scroll-parent"><br><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span><langflow-chat chat_inputs='{"your_key":"value"}' chat_input_field="your_chat_key" flow_id="your_flow_id" host_url="langflow_url"></langflow-chat></span></div></div><br></code></div></div>
|
||
<div class="theme-admonition theme-admonition-tip admonition_xJq3 alert alert--success"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 12 16"><path fill-rule="evenodd" d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>tip</div><div class="admonitionContent_BuS1"><p><code>CUSTOM_ELEMENTS_SCHEMA</code> is a built-in schema that allows Angular to recognize custom elements. Adding <code>CUSTOM_ELEMENTS_SCHEMA</code> tells Angular to allow custom elements in your templates, and it will suppress the warning related to unknown elements like <code>langflow-chat</code>. Notice that you can only use the Chat Widget in components that are part of the module where you added <code>CUSTOM_ELEMENTS_SCHEMA</code>.</p></div></div>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="chat-widget-configuration">Chat widget configuration<a href="#chat-widget-configuration" class="hash-link" aria-label="Direct link to Chat widget configuration" title="Direct link to Chat widget configuration"></a></h2>
|
||
<p>Use the widget API to customize your Chat Widget:</p>
|
||
<div class="theme-admonition theme-admonition-caution 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>caution</div><div class="admonitionContent_BuS1"><p>Props with the type JSON need to be passed as stringified JSONs, with the format {"key":"value"}.</p></div></div>
|
||
<table><thead><tr><th>Prop</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>bot_message_style</td><td>JSON</td><td>No</td><td>Applies custom formatting to bot messages.</td></tr><tr><td>chat_input_field</td><td>String</td><td>Yes</td><td>Defines the type of the input field for chat messages.</td></tr><tr><td>chat_inputs</td><td>JSON</td><td>Yes</td><td>Determines the chat input elements and their respective values.</td></tr><tr><td>chat_output_key</td><td>String</td><td>No</td><td>Specifies which output to display if multiple outputs are available.</td></tr><tr><td>chat_position</td><td>String</td><td>No</td><td>Positions the chat window on the screen (options include: top-left, top-center, top-right, center-left, center-right, bottom-right, bottom-center, bottom-left).</td></tr><tr><td>chat_trigger_style</td><td>JSON</td><td>No</td><td>Styles the chat trigger button.</td></tr><tr><td>chat_window_style</td><td>JSON</td><td>No</td><td>Customizes the overall appearance of the chat window.</td></tr><tr><td>error_message_style</td><td>JSON</td><td>No</td><td>Sets the format for error messages within the chat window.</td></tr><tr><td>flow_id</td><td>String</td><td>Yes</td><td>Identifies the flow that the component is associated with.</td></tr><tr><td>height</td><td>Number</td><td>No</td><td>Sets the height of the chat window in pixels.</td></tr><tr><td>host_url</td><td>String</td><td>Yes</td><td>Specifies the URL of the host for chat component communication.</td></tr><tr><td>input_container_style</td><td>JSON</td><td>No</td><td>Applies styling to the container where chat messages are entered.</td></tr><tr><td>input_style</td><td>JSON</td><td>No</td><td>Sets the style for the chat input field.</td></tr><tr><td>online</td><td>Boolean</td><td>No</td><td>Toggles the online status of the chat component.</td></tr><tr><td>online_message</td><td>String</td><td>No</td><td>Sets a custom message to display when the chat component is online.</td></tr><tr><td>placeholder</td><td>String</td><td>No</td><td>Sets the placeholder text for the chat input field.</td></tr><tr><td>placeholder_sending</td><td>String</td><td>No</td><td>Sets the placeholder text to display while a message is being sent.</td></tr><tr><td>send_button_style</td><td>JSON</td><td>No</td><td>Sets the style for the send button in the chat window.</td></tr><tr><td>send_icon_style</td><td>JSON</td><td>No</td><td>Sets the style for the send icon in the chat window.</td></tr><tr><td>tweaks</td><td>JSON</td><td>No</td><td>Applies additional custom adjustments for the associated flow.</td></tr><tr><td>user_message_style</td><td>JSON</td><td>No</td><td>Determines the formatting for user messages in the chat window.</td></tr><tr><td>width</td><td>Number</td><td>No</td><td>Sets the width of the chat window in pixels.</td></tr><tr><td>window_title</td><td>String</td><td>No</td><td>Sets the title displayed in the chat window's header or title bar.</td></tr></tbody></table>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="tweaks">Tweaks<a href="#tweaks" class="hash-link" aria-label="Direct link to Tweaks" title="Direct link to Tweaks"></a></h2>
|
||
<p>The <strong>Tweaks</strong> tab displays the available parameters for your flow. Modifying the parameters changes the code parameters across all windows. For example, changing the <strong>Chat Input</strong> component's <code>input_value</code> will change that value across all API calls.</p>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="send-image-files-to-your-flow-with-the-api">Send image files to your flow with the API<a href="#send-image-files-to-your-flow-with-the-api" class="hash-link" aria-label="Direct link to Send image files to your flow with the API" title="Direct link to Send image files to your flow with the API"></a></h2>
|
||
<p>For information on sending files to the Langflow API, see <a href="/api-reference-api-examples#upload-image-files">API examples</a>.</p>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="webhook-curl">Webhook cURL<a href="#webhook-curl" class="hash-link" aria-label="Direct link to Webhook cURL" title="Direct link to Webhook cURL"></a></h2>
|
||
<p>When a <strong>Webhook</strong> component is added to the workspace, a new <strong>Webhook cURL</strong> tab becomes available in the <strong>API</strong> pane that contains an HTTP POST request for triggering the webhook component. For example:</p>
|
||
<div class="ch-codeblock not-prose" data-ch-theme="github-dark"><div class="ch-code-wrapper ch-code" data-ch-measured="false"><code class="ch-code-scroll-parent"><br><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>curl -X POST \</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "http://127.0.0.1:7860/api/v1/webhook/**YOUR_FLOW_ID**" \</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> -H 'Content-Type: application/json'\</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> -d '{"any": "data"}'</span></div></div><br></code></div></div>
|
||
<p>To test the <strong>Webhook</strong> component in your flow, see the <a href="/components-data#webhook">Webhook component</a>.</p></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/concepts-objects"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Langflow objects</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/components-agents"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Agents</div></a></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 href="#chat-widget" class="table-of-contents__link toc-highlight">Chat Widget</a><ul><li><a href="#embed-the-chat-widget-into-html" class="table-of-contents__link toc-highlight">Embed the chat widget into HTML</a></li><li><a href="#embed-the-chat-widget-with-react" class="table-of-contents__link toc-highlight">Embed the chat widget with React</a></li><li><a href="#embed-the-chat-widget-with-angular" class="table-of-contents__link toc-highlight">Embed the chat widget with Angular</a></li></ul></li><li><a href="#chat-widget-configuration" class="table-of-contents__link toc-highlight">Chat widget configuration</a></li><li><a href="#tweaks" class="table-of-contents__link toc-highlight">Tweaks</a></li><li><a href="#send-image-files-to-your-flow-with-the-api" class="table-of-contents__link toc-highlight">Send image files to your flow with the API</a></li><li><a href="#webhook-curl" class="table-of-contents__link toc-highlight">Webhook cURL</a></li></ul></div></div></div></div></main></div></div></div><div style="position:fixed;right:20px;bottom:20px;z-index:100;display:flex;align-items:center;gap:10px;cursor:pointer"><div style="background-color:#f6f6f6;border-radius:50%;width:48px;height:48px;display:flex;align-items:center;justify-content:center;box-shadow:0 2px 4px rgba(0,0,0,0.1)"><img src="/img/langflow-icon-black-transparent.svg" style="width:40px" alt="Search"></div></div></div>
|
||
</body>
|
||
</html> |