mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 05:16:40 +08:00
613 lines
158 KiB
HTML
613 lines
158 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/components-processing" data-has-hydrated="false">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="generator" content="Docusaurus v3.8.1">
|
||
<title data-rh="true">Processing components | 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/components-processing"><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="Processing components | Langflow Documentation"><meta data-rh="true" name="description" content="Langflow's Processing components process and transform data within a flow."><meta data-rh="true" property="og:description" content="Langflow's Processing components process and transform data within a flow."><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://docs.langflow.org/components-processing"><link data-rh="true" rel="alternate" href="https://docs.langflow.org/components-processing" hreflang="en"><link data-rh="true" rel="alternate" href="https://docs.langflow.org/components-processing" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://UZK6BDPCVY-dsn.algolia.net" crossorigin="anonymous"><script data-rh="true" type="application/ld+json">{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Processing components","item":"https://docs.langflow.org/components-processing"}]}</script><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-SLQFLQ3KPT"></script>
|
||
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-SLQFLQ3KPT",{})</script>
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml" title="Langflow Documentation" href="/opensearch.xml">
|
||
|
||
|
||
|
||
<script>!function(){var e="analytics",t=window[e]=window[e]||[];if(!t.initialize)if(t.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{t.invoked=!0,t.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","screen","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware","register"],t.factory=function(n){return function(){if(window[e].initialized)return window[e][n].apply(window[e],arguments);var r=Array.prototype.slice.call(arguments);if(["track","screen","alias","group","page","identify"].indexOf(n)>-1){var i=document.querySelector("link[rel='canonical']");r.push({__t:"bpc",c:i&&i.getAttribute("href")||void 0,p:location.pathname,u:location.href,s:location.search,t:document.title,r:document.referrer})}return r.unshift(n),t.push(r),t}};for(var n=0;n<t.methods.length;n++){var r=t.methods[n];t[r]=t.factory(r)}t.load=function(n,r){var i=document.createElement("script");i.type="text/javascript",i.async=!0,i.setAttribute("data-global-segment-analytics-key",e),i.src="https://cdn.segment.com/analytics.js/v1/"+n+"/analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(i,a),t._loadOptions=r},t._writeKey="60AfGDrVxy8nAGJngo3fCYWG4LvhMAlG",t.SNIPPET_VERSION="5.2.0",t.load("60AfGDrVxy8nAGJngo3fCYWG4LvhMAlG"),t.page()}}()</script>
|
||
<script>window.__SCROLL_TRACKING_CONFIG__={selectors:[{selector:"h1, h2, h3, h4, h5, h6",eventName:"Docs.langflow.org - Heading Viewed",properties:{element_type:"heading"}},{selector:".ch-codeblock",eventName:"Docs.langflow.org - Codeblock Viewed",properties:{element_type:"code",language:"helper:codeLanguage"}}]}</script>
|
||
|
||
|
||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@550;600&display=swap">
|
||
<script>!function(){window.semaphore=window.semaphore||[],window.ketch=function(){window.semaphore.push(arguments)};var e=document.createElement("script");e.type="text/javascript",e.src="https://global.ketchcdn.com/web/v3/config/datastax/langflow_org_web/boot.js",e.defer=e.async=!0,document.getElementsByTagName("head")[0].appendChild(e)}()</script>
|
||
<script defer="true">!function(){const e=e=>{if(window.gtag&&e.purposes&&"analytics"in e.purposes&&"targeted_advertising"in e.purposes){const n=!0===e.purposes.analytics?"granted":"denied",t=!0===e.purposes.targeted_advertising?"granted":"denied",a={analytics_storage:n,ad_personalization:t,ad_storage:t,ad_user_data:t};window.gtag("consent","update",a)}};window.ketch&&window.ketch("on","consent",e)}()</script><link rel="stylesheet" href="/assets/css/styles.79069821.css">
|
||
<script src="/assets/js/runtime~main.ce1ba391.js" defer="defer"></script>
|
||
<script src="/assets/js/main.f711f3e7.js" defer="defer"></script>
|
||
</head>
|
||
<body class="navigation-with-keyboard">
|
||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><defs>
|
||
<symbol id="theme-svg-external-link" viewBox="0 0 24 24"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"/></symbol>
|
||
</defs></svg>
|
||
<script>!function(){var t=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme")}catch(t){}}();document.documentElement.setAttribute("data-theme",t||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")),document.documentElement.setAttribute("data-theme-choice",t||"system")}(),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="theme-layout-navbar navbar navbar--fixed-top navbarHideable_m1mJ"><div class="navbar__inner"><div class="theme-layout-navbar-left 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/lf-docs-light.svg" alt="Langflow" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="/img/lf-docs-dark.svg" alt="Langflow" class="themedComponent_mlkZ themedComponent--dark_xIcU"></div></a></div><div class="theme-layout-navbar-right navbar__items navbar__items--right"><a href="https://github.com/langflow-ai/langflow" target="_blank" class="navbar__item navbar__link header-github-link" data-event="Docs.langflow.org - Social Clicked" data-platform="github"></a><a href="https://twitter.com/langflow_ai" target="_blank" class="navbar__item navbar__link header-twitter-link" data-event="Docs.langflow.org - Social Clicked" data-platform="x"></a><a href="https://discord.gg/EqksyE2EX9" target="_blank" class="navbar__item navbar__link header-discord-link" data-event="Docs.langflow.org - Social Clicked" data-platform="discord"></a><div class="toggle_vylO colorModeToggle_DEke"><button class="clean-btn toggleButton_gllP toggleButtonDisabled_aARS" type="button" disabled="" title="system mode" aria-label="Switch between dark and light mode (currently system mode)"><svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" class="toggleIcon_g3eP 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" aria-hidden="true" class="toggleIcon_g3eP 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><svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" class="toggleIcon_g3eP systemToggleIcon_QzmC"><path fill="currentColor" d="m12 21c4.971 0 9-4.029 9-9s-4.029-9-9-9-9 4.029-9 9 4.029 9 9 9zm4.95-13.95c1.313 1.313 2.05 3.093 2.05 4.95s-0.738 3.637-2.05 4.95c-1.313 1.313-3.093 2.05-4.95 2.05v-14c1.857 0 3.637 0.737 4.95 2.05z"></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="theme-layout-main 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/lf-docs-light.svg" alt="Langflow" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="/img/lf-docs-dark.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-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</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="/concepts-overview">Flows</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">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="/mcp-client">Model Context Protocol (MCP)</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-keys-and-authentication">Develop</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-overview">Deploy</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-components">Components reference</a></div><ul 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-components">Components overview</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 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" tabindex="0" href="/components-io">Core components</a></div><ul class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/components-io">Input / Output</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/components-agents">Agents</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 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" tabindex="0" href="/components-models">Models</a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/components-data">Data</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/components-vector-stores">Vector Stores</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 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" tabindex="0" href="/components-processing">Processing</a></div><ul class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/components-processing">Processing components</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/components-prompts">Prompt Template</a></li></ul></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/components-logic">Logic</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/components-helpers">Helpers</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/components-tools">Tools</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/components-memories">Memories</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 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" tabindex="0" href="/components-bundle-components">Bundles</a></div></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="/components-custom-components">Create custom Python components</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="/api-reference-api-examples">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="/contributing-community">Contribute</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="/release-notes">Release notes</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="/troubleshoot">Support</a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 sidebar-ad">
|
||
<a href="https://www.langflow.org/desktop" target="_blank" class="menu__link">
|
||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<g clip-path="url(#clip0_1645_37)">
|
||
<path d="M12 17H20C21.1046 17 22 16.1046 22 15V13M12 17H4C2.89543 17 2 16.1046 2 15V5C2 3.89543 2.89543 3 4 3H10M12 17V21M8 21H12M12 21H16M11.75 10.2917H13.2083L16.125 7.375H17.5833L20.5 4.45833H21.9583M16.125 11.75H17.5833L20.5 8.83333H21.9583M11.75 5.91667H13.2083L16.125 3H17.5833" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||
</g>
|
||
<defs>
|
||
<clipPath id="clip0_1645_37">
|
||
<rect width="24" height="24" fill="white"/>
|
||
</clipPath>
|
||
</defs>
|
||
</svg>
|
||
<div class="sidebar-ad-text-container">
|
||
<span class="sidebar-ad-text">Get started in minutes</span>
|
||
<span class="sidebar-ad-text sidebar-ad-text-gradient">Download Langflow Desktop</span>
|
||
</div>
|
||
</a>
|
||
</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"><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">Components reference</span></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Core components</span></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Processing</span></li><li class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link">Processing components</span></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>Processing components</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>Langflow's <strong>Processing</strong> components process and transform data within a flow.
|
||
They have many uses, including:</p>
|
||
<ul>
|
||
<li>Feed instructions and context to your LLMs and agents with the <a href="#prompt-template"><strong>Prompt Template</strong> component</a>.</li>
|
||
<li>Extract content from larger chunks of data with a <a href="#parser"><strong>Parser</strong> component</a>.</li>
|
||
<li>Filter data with natural language with the <a href="#smart-function"><strong>Smart Function</strong> component</a>.</li>
|
||
<li>Save data to your local machine with the <a href="#save-file"><strong>Save File</strong> component</a>.</li>
|
||
<li>Transform data into a different data type with the <a href="#type-convert"><strong>Type Convert</strong> component</a> to pass it between incompatible components.</li>
|
||
</ul>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="prompt-template">Prompt Template<a href="#prompt-template" class="hash-link" aria-label="Direct link to Prompt Template" title="Direct link to Prompt Template"></a></h2>
|
||
<p>See <a href="/components-prompts"><strong>Prompt Template</strong> component</a>.</p>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="batch-run">Batch Run<a href="#batch-run" class="hash-link" aria-label="Direct link to Batch Run" title="Direct link to Batch Run"></a></h2>
|
||
<p>The <strong>Batch Run</strong> component runs a language model over <em>each row of one text column</em> in a <a href="/data-types#dataframe"><code>DataFrame</code></a>, and then returns a new <code>DataFrame</code> with the original text and an LLM response.
|
||
The output contains the following columns:</p>
|
||
<ul>
|
||
<li><code>text_input</code>: The original text from the input <code>DataFrame</code></li>
|
||
<li><code>model_response</code>: The model's response for each input</li>
|
||
<li><code>batch_index</code>: The 0-indexed processing order for all rows in the <code>DataFrame</code></li>
|
||
<li><code>metadata</code> (optional): Additional information about the processing</li>
|
||
</ul>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="use-the-batch-run-component-in-a-flow">Use the Batch Run component in a flow<a href="#use-the-batch-run-component-in-a-flow" class="hash-link" aria-label="Direct link to Use the Batch Run component in a flow" title="Direct link to Use the Batch Run component in a flow"></a></h3>
|
||
<p>If you pass the <strong>Batch Run</strong> output to a <a href="/components-processing#parser"><strong>Parser</strong> component</a>, you can use variables in the parsing template to reference these keys, such as <code>{text_input}</code> and <code>{model_response}</code>.
|
||
This is demonstrated in the following example.</p>
|
||
<p><img decoding="async" loading="lazy" alt="A batch run component connected to OpenAI and a Parser" src="/assets/images/component-batch-run-19c94fbb0646b2731b37013b84dff1f6.png" width="4000" height="2728" class="img_ev3q"></p>
|
||
<ol>
|
||
<li>
|
||
<p>Connect a <strong>Language Model</strong> component to a <strong>Batch Run</strong> component's <strong>Language model</strong> port.</p>
|
||
</li>
|
||
<li>
|
||
<p>Connect <code>DataFrame</code> output from another component to the <strong>Batch Run</strong> component's <strong>DataFrame</strong> input.
|
||
For example, you could connect a <strong>File</strong> component with a CSV file.</p>
|
||
</li>
|
||
<li>
|
||
<p>In the <strong>Batch Run</strong> component's <strong>Column Name</strong> field, enter the name of the column in the incoming <code>DataFrame</code> that contains the text to process.
|
||
For example, if you want to extract text from a <code>name</code> column in a CSV file, enter <code>name</code> in the <strong>Column Name</strong> field.</p>
|
||
</li>
|
||
<li>
|
||
<p>Connect the <strong>Batch Run</strong> component's <strong>Batch Results</strong> output to a <strong>Parser</strong> component's <strong>DataFrame</strong> input.</p>
|
||
</li>
|
||
<li>
|
||
<p>Optional: In the <strong>Batch Run</strong> <a href="/concepts-components#component-menus">component's header menu</a>, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sliders-horizontal" aria-hidden="true"><line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line></svg> <strong>Controls</strong>, enable the <strong>System Message</strong> parameter, click <strong>Close</strong>, and then enter an instruction for how you want the LLM to process each cell extracted from the file.
|
||
For example, <code>Create a business card for each name.</code></p>
|
||
</li>
|
||
<li>
|
||
<p>In the <strong>Parser</strong> component's <strong>Template</strong> field, enter a template for processing the <strong>Batch Run</strong> component's new <code>DataFrame</code> columns (<code>text_input</code>, <code>model_response</code>, and <code>batch_index</code>):</p>
|
||
<p>For example, this template uses three columns from the resulting, post-batch <code>DataFrame</code>:</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>record_number: {batch_index}, name: {text_input}, summary: {model_response}</span></div></div><br></code></div></div>
|
||
</li>
|
||
<li>
|
||
<p>To test the processing, click the <strong>Parser</strong> component, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-play" aria-hidden="true"><polygon points="6 3 20 12 6 21 6 3"></polygon></svg> <strong>Run component</strong>, and then click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text-search" aria-hidden="true"><path d="M21 6H3"></path><path d="M10 12H3"></path><path d="M10 18H3"></path><circle cx="17" cy="15" r="3"></circle><path d="m21 19-1.9-1.9"></path></svg> <strong>Inspect output</strong> to view the final <code>DataFrame</code>.</p>
|
||
<p>You can also connect a <strong>Chat Output</strong> component to the <strong>Parser</strong> component if you want to see the output in the <strong>Playground</strong>.</p>
|
||
</li>
|
||
</ol>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="batch-run-parameters">Batch Run parameters<a href="#batch-run-parameters" class="hash-link" aria-label="Direct link to Batch Run parameters" title="Direct link to Batch Run parameters"></a></h3>
|
||
<p>Some parameters are hidden by default in the visual editor.
|
||
You can modify all parameters through the <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sliders-horizontal" aria-hidden="true"><line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line></svg> <strong>Controls</strong> in the <a href="/concepts-components#component-menus">component's header menu</a>.</p>
|
||
<table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>model</td><td>HandleInput</td><td>Input parameter. Connect the 'Language Model' output from a <strong>Language Model</strong> component. Required.</td></tr><tr><td>system_message</td><td>MultilineInput</td><td>Input parameter. A multi-line system instruction for all rows in the DataFrame.</td></tr><tr><td>df</td><td>DataFrameInput</td><td>Input parameter. The DataFrame whose column is treated as text messages, as specified by 'column_name'. Required.</td></tr><tr><td>column_name</td><td>MessageTextInput</td><td>Input parameter. The name of the DataFrame column to treat as text messages. If empty, all columns are formatted in TOML.</td></tr><tr><td>output_column_name</td><td>MessageTextInput</td><td>Input parameter. Name of the column where the model's response is stored. Default=<code>model_response</code>.</td></tr><tr><td>enable_metadata</td><td>BoolInput</td><td>Input parameter. If True, add metadata to the output DataFrame.</td></tr><tr><td>batch_results</td><td>DataFrame</td><td>Output parameter. A DataFrame with all original columns plus the model's response column.</td></tr></tbody></table>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="data-operations">Data Operations<a href="#data-operations" class="hash-link" aria-label="Direct link to Data Operations" title="Direct link to Data Operations"></a></h2>
|
||
<p>The <strong>Data Operations</strong> component performs operations on <a href="/data-types#data"><code>Data</code></a> objects, including extracting, filtering, and editing keys and values in the <code>Data</code>.
|
||
For all options, see <a href="#available-data-operations">Available data operations</a>.
|
||
The output is a new <code>Data</code> object containing the modified data after running the selected operation.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="use-the-data-operations-component-in-a-flow">Use the Data Operations component in a flow<a href="#use-the-data-operations-component-in-a-flow" class="hash-link" aria-label="Direct link to Use the Data Operations component in a flow" title="Direct link to Use the Data Operations component in a flow"></a></h3>
|
||
<p>The following example demonstrates how to use a <strong>Data Operations</strong> component in a flow using data from a webhook payload:</p>
|
||
<ol>
|
||
<li>
|
||
<p>Create a flow with a <strong>Webhook</strong> component and a <strong>Data Operations</strong> component, and then connect the <strong>Webhook</strong> component's output to the <strong>Data Operations</strong> component's <strong>Data</strong> input.</p>
|
||
<p>All operations in the <strong>Data Operations</strong> component require at least one <code>Data</code> input from another component.
|
||
If the preceding component doesn't produce <code>Data</code> output, you can use another component, such as the <strong>Type Convert</strong> component, to reformat the data before passing it to the <strong>Data Operations</strong> component.
|
||
Alternatively, you could consider using a component that is designed to process the original data type, such as the <strong>Parser</strong> or <strong>DataFrame Operations</strong> components.</p>
|
||
</li>
|
||
<li>
|
||
<p>In the <strong>Operations</strong> field, select the operation you want to perform on the incoming <code>Data</code>.
|
||
For this example, select the <strong>Select Keys</strong> operation.</p>
|
||
<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>You can select only one operation.
|
||
If you need to perform multiple operations on the data, you can chain multiple <strong>Data Operations</strong> components together to execute each operation in sequence.
|
||
For more complex multi-step operations, consider using a component like the <strong>Smart Function</strong> component.</p></div></div>
|
||
</li>
|
||
<li>
|
||
<p>Under <strong>Select Keys</strong>, add keys for <code>name</code>, <code>username</code>, and <code>email</code>.
|
||
Click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus" aria-hidden="true"><path d="M5 12h14"></path><path d="M12 5v14"></path></svg> <strong>Add more</strong> to add a field for each key.</p>
|
||
<p>For this example, assume that the webhook will receive consistent payloads that always contain <code>name</code>, <code>username</code>, and <code>email</code> keys.
|
||
The <strong>Select Keys</strong> operation extracts the value of these keys from each incoming payload.</p>
|
||
</li>
|
||
<li>
|
||
<p>Optional: If you want to view the output in the <strong>Playground</strong>, connect the <strong>Data Operations</strong> component's output to a <strong>Chat Output</strong> component.</p>
|
||
<p><img decoding="async" loading="lazy" alt="A flow with Webhook, Data Operations, and Chat Output components" src="/assets/images/component-data-operations-select-key-80bade862d29f2851b01ee26413d495f.png" width="4000" height="1920" class="img_ev3q"></p>
|
||
</li>
|
||
<li>
|
||
<p>To test the flow, send the following request to your flow's webhook endpoint.
|
||
For more information about the webhook endpoint, see <a href="/webhook">Trigger flows with webhooks</a>.</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">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span>curl -X POST "http://$LANGFLOW_SERVER_URL/api/v1/webhook/$FLOW_ID" \</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</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">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span>-H "x-api-key: $LANGFLOW_API_KEY" \</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span>-d '{</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "id": 1,</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "name": "Leanne Graham",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "username": "Bret",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "email": "Sincere@april.biz",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "address": {</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "street": "Main Street",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "suite": "Apt. 556",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "city": "Springfield",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "zipcode": "92998-3874",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "geo": {</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "lat": "-37.3159",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "lng": "81.1496"</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> }</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> },</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "phone": "1-770-736-8031 x56442",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "website": "hildegard.org",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "company": {</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "name": "Acme-Corp",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "catchPhrase": "Multi-layered client-server neural-net",</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> "bs": "harness real-time e-markets"</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span> }</span></div></div><div><span class="ch-code-line-number">_<!-- -->26</span><div style="display:inline-block;margin-left:16px"><span>}'</span></div></div><br></code></div></div>
|
||
</li>
|
||
<li>
|
||
<p>To view the <code>Data</code> resulting from the <strong>Select Keys</strong> operation, do one of the following:</p>
|
||
<ul>
|
||
<li>If you attached a <strong>Chat Output</strong> component, open the <strong>Playground</strong> to see the result as a chat message.</li>
|
||
<li>Click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text-search" aria-hidden="true"><path d="M21 6H3"></path><path d="M10 12H3"></path><path d="M10 18H3"></path><circle cx="17" cy="15" r="3"></circle><path d="m21 19-1.9-1.9"></path></svg> <strong>Inspect output</strong> on the <strong>Data Operations</strong> component.</li>
|
||
</ul>
|
||
</li>
|
||
</ol>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="data-operations-parameters">Data Operations parameters<a href="#data-operations-parameters" class="hash-link" aria-label="Direct link to Data Operations parameters" title="Direct link to Data Operations parameters"></a></h3>
|
||
<p>Many parameters are conditional based on the selected <strong>Operation</strong> (<code>operation</code>).</p>
|
||
<table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>data</td><td>Data</td><td>Input parameter. The <code>Data</code> object to operate on.</td></tr><tr><td>operation</td><td>Operation</td><td>Input parameter. The operation to perform on the data. See <a href="#available-data-operations">Available data operations</a></td></tr><tr><td>select_keys_input</td><td>Select Keys</td><td>Input parameter. A list of keys to select from the data.</td></tr><tr><td>filter_key</td><td>Filter Key</td><td>Input parameter. The key to filter by.</td></tr><tr><td>operator</td><td>Comparison Operator</td><td>Input parameter. The operator to apply for comparing values.</td></tr><tr><td>filter_values</td><td>Filter Values</td><td>Input parameter. A list of values to filter by.</td></tr><tr><td>append_update_data</td><td>Append or Update</td><td>Input parameter. The data to append or update the existing data with.</td></tr><tr><td>remove_keys_input</td><td>Remove Keys</td><td>Input parameter. A list of keys to remove from the data.</td></tr><tr><td>rename_keys_input</td><td>Rename Keys</td><td>Input parameter. A list of keys to rename in the data.</td></tr></tbody></table>
|
||
<h4 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="available-data-operations">Available data operations<a href="#available-data-operations" class="hash-link" aria-label="Direct link to Available data operations" title="Direct link to Available data operations"></a></h4>
|
||
<p>Options for the <code>operations</code> input parameter are as follows.
|
||
All operations act on an incoming <code>Data</code> object.</p>
|
||
<table><thead><tr><th>Name</th><th>Required Inputs</th><th>Process</th></tr></thead><tbody><tr><td>Select Keys</td><td><code>select_keys_input</code></td><td>Selects specific keys from the data.</td></tr><tr><td>Literal Eval</td><td>None</td><td>Evaluates string values as Python literals.</td></tr><tr><td>Combine</td><td>None</td><td>Combines multiple data objects into one.</td></tr><tr><td>Filter Values</td><td><code>filter_key</code>, <code>filter_values</code>, <code>operator</code></td><td>Filters data based on key-value pair.</td></tr><tr><td>Append or Update</td><td><code>append_update_data</code></td><td>Adds or updates key-value pairs.</td></tr><tr><td>Remove Keys</td><td><code>remove_keys_input</code></td><td>Removes specified keys from the data.</td></tr><tr><td>Rename Keys</td><td><code>rename_keys_input</code></td><td>Renames keys in the data.</td></tr></tbody></table>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="dataframe-operations">DataFrame Operations<a href="#dataframe-operations" class="hash-link" aria-label="Direct link to DataFrame Operations" title="Direct link to DataFrame Operations"></a></h2>
|
||
<p>The <strong>DataFrame Operations</strong> component performs operations on <a href="/data-types#dataframe"><code>DataFrame</code></a> (table) rows and columns, including schema changes, record changes, sorting, and filtering.
|
||
For all options, see <a href="#dataframe-operations-parameters">DataFrame Operations parameters</a>.</p>
|
||
<p>The output is a new <code>DataFrame</code> containing the modified data after running the selected operation.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="use-the-dataframe-operations-component-in-a-flow">Use the DataFrame Operations component in a flow<a href="#use-the-dataframe-operations-component-in-a-flow" class="hash-link" aria-label="Direct link to Use the DataFrame Operations component in a flow" title="Direct link to Use the DataFrame Operations component in a flow"></a></h3>
|
||
<p>The following steps explain how to configure a <strong>DataFrame Operations</strong> component in a flow.
|
||
You can follow along with an example or use your own flow.
|
||
The only requirement is that the preceding component must create <code>DataFrame</code> output that you can pass to the <strong>DataFrame Operations</strong> component.</p>
|
||
<ol>
|
||
<li>
|
||
<p>Create a new flow or use an existing flow.</p>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Example: API response extraction flow</summary><div><div class="collapsibleContent_i85q"><p>The following example flow uses five components to extract <code>Data</code> from an API response, transform it to a <code>DataFrame</code>, and then perform further processing on the tabular data using a <strong>DataFrame Operations</strong> component.
|
||
The sixth component, <strong>Chat Output</strong>, is optional in this example.
|
||
It only serves as a convenient way for you to view the final output in the <strong>Playground</strong>, rather than inspecting the component logs.</p><p><img decoding="async" loading="lazy" alt="A flow that ingests an API response, extracts it to a DataFrame with a Smart Function component, and the processes it through a DataFrame Operations component" src="/assets/images/component-dataframe-operations-031488ccf4e3d3378f8842f0ea10682c.png" width="4000" height="2120" class="img_ev3q"></p><p>If you want to use this example to test the <strong>DataFrame Operations</strong> component, do the following:</p><ol>
|
||
<li>
|
||
<p>Create a flow with the following components:</p>
|
||
<ul>
|
||
<li><strong>API Request</strong></li>
|
||
<li><strong>Language Model</strong></li>
|
||
<li><strong>Smart Function</strong></li>
|
||
<li><strong>Type Convert</strong></li>
|
||
</ul>
|
||
</li>
|
||
<li>
|
||
<p>Configure the <a href="#smart-function"><strong>Smart Function</strong> component</a> and its dependencies:</p>
|
||
<ul>
|
||
<li><strong>API Request</strong>: Configure the <a href="/components-data#api-request"><strong>API Request</strong> component</a> to get JSON data from an endpoint of your choice, and then connect the <strong>API Response</strong> output to the <strong>Smart Function</strong> component's <strong>Data</strong> input.</li>
|
||
<li><strong>Language Model</strong>: Select your preferred provider and model, and then enter a valid API key.
|
||
Change the output to <strong>Language Model</strong>, and then connect the <code>LanguageModel</code> output to the <strong>Smart Function</strong> component's <strong>Language Model</strong> input.</li>
|
||
<li><strong>Smart Function</strong>: In the <strong>Instructions</strong> field, enter natural language instructions to extract data from the API response.
|
||
Your instructions depend on the response content and desired outcome.
|
||
For example, if the response contains a large <code>result</code> field, you might provide instructions like <code>explode the result field out into a Data object</code>.</li>
|
||
</ul>
|
||
</li>
|
||
<li>
|
||
<p>Convert the <strong>Smart Function</strong> component's <code>Data</code> output to <code>DataFrame</code>:</p>
|
||
<ol>
|
||
<li>Connect the <strong>Filtered Data</strong> output to the <strong>Type Convert</strong> component's <strong>Data</strong> input.</li>
|
||
<li>Set the <strong>Type Convert</strong> component's <strong>Output Type</strong> to <strong>DataFrame</strong>.</li>
|
||
</ol>
|
||
</li>
|
||
</ol><p>Now the flow is ready for you to add the <strong>DataFrame Operations</strong> component.</p></div></div></details>
|
||
</li>
|
||
<li>
|
||
<p>Add a <strong>DataFrame Operations</strong> component to the flow, and then connect <code>DataFrame</code> output from another component to the <strong>DataFrame</strong> input.</p>
|
||
<p>All operations in the <strong>DataFrame Operations</strong> component require at least one <code>DataFrame</code> input from another component.
|
||
If a component doesn't produce <code>DataFrame</code> output, you can use another component, such as the <strong>Type Convert</strong> component, to reformat the data before passing it to the <strong>DataFrame Operations</strong> component.
|
||
Alternatively, you could consider using a component that is designed to process the original data type, such as the <strong>Parser</strong> or <strong>Data Operations</strong> components.</p>
|
||
<p>If you are following along with the example flow, connect the <strong>Type Convert</strong> component's <strong>DataFrame Output</strong> port to the <strong>DataFrame</strong> input.</p>
|
||
</li>
|
||
<li>
|
||
<p>In the <strong>Operations</strong> field, select the operation you want to perform on the incoming <code>DataFrame</code>.
|
||
For example, the <strong>Filter</strong> operation filters the rows based on a specified column and value.</p>
|
||
<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>You can select only one operation.
|
||
If you need to perform multiple operations on the data, you can chain multiple <strong>DataFrame Operations</strong> components together to execute each operation in sequence.
|
||
For more complex multi-step operations, like dramatic schema changes or pivots, consider using an LLM-powered component, like the <strong>Structured Output</strong> or <strong>Smart Function</strong> component, as a replacement or preparation for the <strong>DataFrame Operations</strong> component.</p></div></div>
|
||
<p>If you're following along with the example flow, select any operation that you want to apply to the data that was extracted by the <strong>Smart Function</strong> component.
|
||
To view the contents of the incoming <code>DataFrame</code>, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-play" aria-hidden="true"><polygon points="6 3 20 12 6 21 6 3"></polygon></svg> <strong>Run component</strong> on the <strong>Type Convert</strong> component, and then <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text-search" aria-hidden="true"><path d="M21 6H3"></path><path d="M10 12H3"></path><path d="M10 18H3"></path><circle cx="17" cy="15" r="3"></circle><path d="m21 19-1.9-1.9"></path></svg> <strong>Inspect output</strong>.
|
||
If the <code>DataFrame</code> seems malformed, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text-search" aria-hidden="true"><path d="M21 6H3"></path><path d="M10 12H3"></path><path d="M10 18H3"></path><circle cx="17" cy="15" r="3"></circle><path d="m21 19-1.9-1.9"></path></svg> <strong>Inspect output</strong> on each upstream component to determine where the error occurs, and then modify your flow's configuration as needed.
|
||
For example, if the <strong>Smart Function</strong> component didn't extract the expected fields, modify your instructions or verify that the given fields are present in the <strong>API Response</strong> output.</p>
|
||
</li>
|
||
<li>
|
||
<p>Configure the operation's parameters.
|
||
The specific parameters depend on the selected operation.
|
||
For example, if you select the <strong>Filter</strong> operation, you must define a filter condition using the <strong>Column Name</strong>, <strong>Filter Value</strong>, and <strong>Filter Operator</strong> parameters.
|
||
For more information, see <a href="#dataframe-operations-parameters">DataFrame Operations parameters</a></p>
|
||
</li>
|
||
<li>
|
||
<p>To test the flow, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-play" aria-hidden="true"><polygon points="6 3 20 12 6 21 6 3"></polygon></svg> <strong>Run component</strong> on the <strong>DataFrame Operations</strong> component, and then click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text-search" aria-hidden="true"><path d="M21 6H3"></path><path d="M10 12H3"></path><path d="M10 18H3"></path><circle cx="17" cy="15" r="3"></circle><path d="m21 19-1.9-1.9"></path></svg> <strong>Inspect output</strong> to view the new <code>DataFrame</code> created from the <strong>Filter</strong> operation.</p>
|
||
<p>If you want to view the output in the <strong>Playground</strong>, connect the <strong>DataFrame Operations</strong> component's output to a <strong>Chat Output</strong> component, rerun the <strong>DataFrame Operations</strong> component, and then click <strong>Playground</strong>.</p>
|
||
</li>
|
||
</ol>
|
||
<p>For another example, see <a href="/components-logic#conditional-looping">Conditional looping</a>.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="dataframe-operations-parameters">DataFrame Operations parameters<a href="#dataframe-operations-parameters" class="hash-link" aria-label="Direct link to DataFrame Operations parameters" title="Direct link to DataFrame Operations parameters"></a></h3>
|
||
<p>Most <strong>DataFrame Operations</strong> parameters are conditional because they only apply to specific operations.</p>
|
||
<p>The only permanent parameters are <strong>DataFrame</strong> (<code>df</code>), which is the <code>DataFrame</code> input, and <strong>Operation</strong> (<code>operation</code>), which is the operation to perform on the <code>DataFrame</code>.
|
||
Once you select an operation, the conditional parameters for that operation appear on the <strong>DataFrame Operations</strong> component.</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">Add Column</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Drop Column</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Filter</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Head</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Rename Column</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Replace Value</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Select Columns</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Sort</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Tail</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Drop Duplicates</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><p>The <strong>Add Column</strong> operation allows you to add a new column to the <code>DataFrame</code> with a constant value.</p><p>The parameters are <strong>New Column Name</strong> (<code>new_column_name</code>) and <strong>New Column Value</strong> (<code>new_column_value</code>).</p></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Drop Column</strong> operation allows you to remove a column from the <code>DataFrame</code>, specified by <strong>Column Name</strong> (<code>column_name</code>).</p></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Filter</strong> operation allows you to filter the <code>DataFrame</code> based on a specified condition.
|
||
The output is a <code>DataFrame</code> containing only the rows that matched the filter condition.</p><p>Provide the following parameters:</p><ul>
|
||
<li><strong>Column Name</strong> (<code>column_name</code>): The name of the column to filter on.</li>
|
||
<li><strong>Filter Value</strong> (<code>filter_value</code>): The value to filter on.</li>
|
||
<li><strong>Filter Operator</strong> (<code>filter_operator</code>): The operator to use for filtering, one of <code>equals</code> (default), <code>not equals</code>, <code>contains</code>, <code>starts with</code>, <code>ends with</code>, <code>greater than</code>, or <code>less than</code>.</li>
|
||
</ul></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Head</strong> operation allows you to retrieve the first <code>n</code> rows of the <code>DataFrame</code>, where <code>n</code> is set in <strong>Number of Rows</strong> (<code>num_rows</code>).
|
||
The default is <code>5</code>.</p><p>The output is a <code>DataFrame</code> containing only the selected rows.</p></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Rename Column</strong> operation allows you to rename an existing column in the <code>DataFrame</code>.</p><p>The parameters are <strong>Column Name</strong> (<code>column_name</code>), which is the current name, and <strong>New Column Name</strong> (<code>new_column_name</code>).</p></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Replace Value</strong> operation allows you to replace values in a specific column of the <code>DataFrame</code>.
|
||
This operation replaces a target value with a new value.
|
||
All cells matching the target value are replaced with the new value in the new <code>DataFrame</code> output.</p><p>Provide the following parameters:</p><ul>
|
||
<li><strong>Column Name</strong> (<code>column_name</code>): The name of the column to modify.</li>
|
||
<li><strong>Value to Replace</strong> (<code>replace_value</code>): The value that you want to replace.</li>
|
||
<li><strong>Replacement Value</strong> (<code>replacement_value</code>): The new value to use.</li>
|
||
</ul></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Select Columns</strong> operation allows you to select one or more specific columns from the <code>DataFrame</code>.</p><p>Provide a list of column names in <strong>Columns to Select</strong> (<code>columns_to_select</code>).
|
||
In the visual editor, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus" aria-hidden="true"><path d="M5 12h14"></path><path d="M12 5v14"></path></svg> <strong>Add More</strong> to add multiple fields, and then enter one column name in each field.</p><p>The output is a <code>DataFrame</code> containing only the specified columns.</p></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Sort</strong> operation allows you to sort the <code>DataFrame</code> on a specific column in ascending or descending order.</p><p>Provide the following parameters:</p><ul>
|
||
<li><strong>Column Name</strong> (<code>column_name</code>): The name of the column to sort on.</li>
|
||
<li><strong>Sort Ascending</strong> (<code>ascending</code>): Whether to sort in ascending or descending order. If enabled (true), sorts in ascending order; if disabled (false), sorts in descending order. Default: Enabled (true)</li>
|
||
</ul></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Tail</strong> operation allows you to retrieve the last <code>n</code> rows of the <code>DataFrame</code>, where <code>n</code> is set in <strong>Number of Rows</strong> (<code>num_rows</code>).
|
||
The default is <code>5</code>.</p><p>The output is a <code>DataFrame</code> containing only the selected rows.</p></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>The <strong>Drop Duplicates</strong> operation removes rows from the <code>DataFrame</code> by identifying all duplicate values within a single column.</p><p>The only parameter is the <strong>Column Name</strong> (<code>column_name</code>).</p><p>When the flow runs, all rows with duplicate values in the given column are removed.
|
||
The output is a <code>DataFrame</code> containing all columns from the original <code>DataFrame</code>, but only rows with non-duplicate values.</p></div></div></div>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="llm-router">LLM Router<a href="#llm-router" class="hash-link" aria-label="Direct link to LLM Router" title="Direct link to LLM Router"></a></h2>
|
||
<p>The <strong>LLM Router</strong> component routes requests to the most appropriate LLM based on <a href="https://openrouter.ai/docs/quickstart" target="_blank" rel="noopener noreferrer">OpenRouter</a> model specifications.</p>
|
||
<p>To use the component in a flow, you connect multiple <strong>Language Model</strong> components to the <strong>LLM Router</strong> components.
|
||
One model is the judge LLM that analyzes input messages to understand the evaluation context, selects the most appropriate model from the other attached LLMs, and then routes the input to the selected model.
|
||
The selected model processes the input, and then returns the generated response.</p>
|
||
<p>The following example flow has three <strong>Language Model</strong> components.
|
||
One is the judge LLM, and the other two are in the LLM pool for request routing.
|
||
The <strong>Chat Input</strong> and <strong>Chat Output</strong> components create a seamless chat interaction where you send a message and receive a response without any user awareness of the underlying routing.</p>
|
||
<p><img decoding="async" loading="lazy" alt="LLM Router component" src="/assets/images/component-llm-router-1b417082a0208a70065bc177a78fab67.png" width="3316" height="2492" class="img_ev3q"></p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="llm-router-parameters">LLM Router parameters<a href="#llm-router-parameters" class="hash-link" aria-label="Direct link to LLM Router parameters" title="Direct link to LLM Router parameters"></a></h3>
|
||
<p>Some parameters are hidden by default in the visual editor.
|
||
You can modify all parameters through the <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sliders-horizontal" aria-hidden="true"><line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line></svg> <strong>Controls</strong> in the <a href="/concepts-components#component-menus">component's header menu</a>.</p>
|
||
<table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td><code>models</code></td><td><strong>Language Models</strong></td><td>Input parameter. Connect <a href="/data-types#languagemodel"><code>LanguageModel</code></a> output from multiple <a href="/components-models"><strong>Language Model</strong> components</a> to create a pool of models. The <code>judge_llm</code> selects models from this pool when routing requests. The first model you connect is the default model if there is a problem with model selection or routing.</td></tr><tr><td><code>input_value</code></td><td><strong>Input</strong></td><td>Input parameter. The incoming query to be routed to the model selected by the judge LLM.</td></tr><tr><td><code>judge_llm</code></td><td><strong>Judge LLM</strong></td><td>Input parameter. Connect <code>LanguageModel</code> output from <em>one</em> <strong>Language Model</strong> component to serve as the judge LLM for request routing.</td></tr><tr><td><code>optimization</code></td><td><strong>Optimization</strong></td><td>Input parameter. Set a preferred characteristic for model selection by the judge LLM. The options are <code>quality</code> (highest response quality), <code>speed</code> (fastest response time), <code>cost</code> (most cost-effective model), or <code>balanced</code> (equal weight for quality, speed, and cost). Default: <code>balanced</code></td></tr><tr><td><code>use_openrouter_specs</code></td><td><strong>Use OpenRouter Specs</strong></td><td>Input parameter. Whether to fetch model specifications from the OpenRouter API.</td></tr><tr><td>If false, only the model name is provided to the judge LLM. Default: Enabled (true)</td><td></td><td></td></tr><tr><td><code>timeout</code></td><td><strong>API Timeout</strong></td><td>Input parameter. Set a timeout duration in seconds for API requests made by the router. Default: <code>10</code></td></tr><tr><td><code>fallback_to_first</code></td><td><strong>Fallback to First Model</strong></td><td>Input parameter. Whether to use the first LLM in <code>models</code> as a backup if routing fails to reach the selected model. Default: Enabled (true)</td></tr></tbody></table>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="llm-router-outputs">LLM Router outputs<a href="#llm-router-outputs" class="hash-link" aria-label="Direct link to LLM Router outputs" title="Direct link to LLM Router outputs"></a></h3>
|
||
<p>The <strong>LLM Router</strong> component provides three output options.
|
||
You can set the desired output type near the component's output port.</p>
|
||
<ul>
|
||
<li>
|
||
<p><strong>Output</strong>: A <code>Message</code> containing the response to the original query as generated by the selected LLM.
|
||
Use this output for regular chat interactions.</p>
|
||
</li>
|
||
<li>
|
||
<p><strong>Selected Model Info</strong>: A <code>Data</code> object containing information about the selected model, such as its name and version.</p>
|
||
</li>
|
||
<li>
|
||
<p><strong>Routing Decision</strong>: A <code>Message</code> containing the judge model's reasoning for selecting a particular model, including input query length and number of models considered.
|
||
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>Model Selection Decision:</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>- Selected Model Index: 0</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>- Selected Langflow Model Name: gpt-4o-mini</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>- Selected API Model ID (if resolved): openai/gpt-4o-mini</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>- Optimization Preference: cost</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>- Input Query Length: 27 characters (~5 tokens)</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>- Number of Models Considered: 2</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>- Specifications Source: OpenRouter API</span></div></div><br></code></div></div>
|
||
<p>This is useful for debugging if you feel the judge model isn't selecting the best model.</p>
|
||
</li>
|
||
</ul>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="parser">Parser<a href="#parser" class="hash-link" aria-label="Direct link to Parser" title="Direct link to Parser"></a></h2>
|
||
<p>The <strong>Parser</strong> component extracts text from structured data (<code>DataFrame</code> or <code>Data</code>) using a template or direct stringification.
|
||
The output is a <code>Message</code> containing the parsed text.</p>
|
||
<p>This is a versatile component for data extraction and manipulation in your flows.
|
||
For examples of <strong>Parser</strong> components in flows, see the following:</p>
|
||
<ul>
|
||
<li><a href="#batch-run"><strong>Batch Run</strong> component example</a></li>
|
||
<li><a href="#structured-output"><strong>Structured Output</strong> component example</a></li>
|
||
<li><strong>Financial Report Parser</strong> template</li>
|
||
<li><a href="/webhook">Trigger flows with webhooks</a></li>
|
||
<li><a href="/chat-with-rag">Create a vector RAG chatbot</a></li>
|
||
</ul>
|
||
<p><img decoding="async" loading="lazy" alt="A flow that uses a Parser component to extract text from a Structured Output component." src="/assets/images/component-parser-1d1d72593f02991e5b14b6b1c112a744.png" width="4000" height="2202" class="img_ev3q"></p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="parsing-modes">Parsing modes<a href="#parsing-modes" class="hash-link" aria-label="Direct link to Parsing modes" title="Direct link to Parsing modes"></a></h3>
|
||
<p>The <strong>Parser</strong> component has two modes: <strong>Parser</strong> and <strong>Stringify</strong>.</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">Parser (template) mode</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Stringify mode</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><p>In <strong>Parser</strong> mode, you create a template for text output that can include literal strings and variables for extracted keys.</p><p>Use curly braces to define variables anywhere in the template.
|
||
Variables must match keys in the <code>DataFrame</code> or <code>Data</code> input, such as column names.
|
||
For example, <code>{name}</code> extracts the value of a <code>name</code> key.
|
||
For more information about the content and structure of <code>DataFrame</code> and <code>Data</code> objects, see <a href="/data-types">Langflow data types</a>.</p><p>When the flow runs, the <strong>Parser</strong> component iterates over the input, producing a <code>Message</code> for each parsed item.
|
||
For example, parsing a <code>DataFrame</code> creates a <code>Message</code> for each row, populated with the unique values from that row.</p><details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Employee summary template</summary><div><div class="collapsibleContent_i85q"><p>This example template extracts employee data into a natural language summary about an employee's hire date and current role:</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>{employee_first_name} {employee_last_name} was hired on {start_date}.</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>Their current position is {job_title} ({grade}).</span></div></div><br></code></div></div><p>The resulting <code>Message</code> output replaces the variables with the corresponding extracted values.
|
||
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>Renlo Kai was hired on 11-July-2017.</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>Their current position is Software Engineer (Principal).</span></div></div><br></code></div></div></div></div></details><details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Employee profile template</summary><div><div class="collapsibleContent_i85q"><p>This example template uses Markdown syntax and extracted employee data to create an employee profile:</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># Employee Profile</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>## Personal Information</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>- **Name:** {name}</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>- **ID:** {id}</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>- **Email:** {email}</span></div></div><br></code></div></div><p>When the flow runs, the <strong>Parser</strong> component iterates over each row of the <code>DataFrame</code>, populating the template's variables with the appropriate extracted values.
|
||
The resulting text for each row is output as a <a href="/data-types#message"><code>Message</code></a>.</p></div></div></details><p>The following parameters are available in <strong>Parser</strong> mode.</p><p>Some parameters are hidden by default in the visual editor.
|
||
You can modify all parameters through the <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sliders-horizontal" aria-hidden="true"><line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line></svg> <strong>Controls</strong> in the <a href="/concepts-components#component-menus">component's header menu</a>.</p><table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>input_data</td><td>Data or DataFrame</td><td>Input parameter. The <code>Data</code> or <code>DataFrame</code> input to parse.</td></tr><tr><td>pattern</td><td>Template</td><td>Input parameter. The formatting template using plaintext and variables for keys (<code>{KEY_NAME}</code>). See the preceding examples for more information.</td></tr><tr><td>sep</td><td>Separator</td><td>Input parameter. A string defining the separator for rows or lines. Default: <code>\n</code> (new line).</td></tr><tr><td>clean_data</td><td>Clean Data</td><td>Whether to remove empty rows and lines in each cell or key of the <code>DataFrame</code> or <code>Data</code> input. Default: Enabled (true)</td></tr></tbody></table></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>Use <strong>Stringify</strong> mode to convert the entire input directly to text.
|
||
This mode doesn't support templates or key selection.</p><p>The following parameters are available in <strong>Stringify</strong> mode.</p><p>Some parameters are hidden by default in the visual editor.
|
||
You can modify all parameters through the <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sliders-horizontal" aria-hidden="true"><line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line></svg> <strong>Controls</strong> in the <a href="/concepts-components#component-menus">component's header menu</a>.</p><table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>input_data</td><td>Data or DataFrame</td><td>Input parameter. The <code>Data</code> or <code>DataFrame</code> input to parse.</td></tr><tr><td>sep</td><td>Separator</td><td>Input parameter. A string defining the separator for rows or lines. Default: <code>\n</code> (new line).</td></tr><tr><td>clean_data</td><td>Clean Data</td><td>Whether to remove empty rows and lines in each cell or key of the <code>DataFrame</code> or <code>Data</code> input. Default: Enabled (true)</td></tr></tbody></table></div></div></div>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="test-and-troubleshoot-parsed-text">Test and troubleshoot parsed text<a href="#test-and-troubleshoot-parsed-text" class="hash-link" aria-label="Direct link to Test and troubleshoot parsed text" title="Direct link to Test and troubleshoot parsed text"></a></h3>
|
||
<p>To test the <strong>Parser</strong> component, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-play" aria-hidden="true"><polygon points="6 3 20 12 6 21 6 3"></polygon></svg> <strong>Run component</strong>, and then click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text-search" aria-hidden="true"><path d="M21 6H3"></path><path d="M10 12H3"></path><path d="M10 18H3"></path><circle cx="17" cy="15" r="3"></circle><path d="m21 19-1.9-1.9"></path></svg> <strong>Inspect output</strong> to see the <code>Message</code> output with the parsed text.
|
||
You can also connect a <strong>Chat Output</strong> component if you want to view the output in the <strong>Playground</strong>.</p>
|
||
<p>If the <code>Message</code> output from the <strong>Parser</strong> component has empty or unexpected values, there might be a mapping error between the input and the parsing mode, the input has empty values, or the input isn't suitable for plaintext extraction.</p>
|
||
<p>For example, assume you use the following template to parse a <code>DataFrame</code>:</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>{employee_first_name} {employee_last_name} is a {job_title} ({grade}).</span></div></div><br></code></div></div>
|
||
<p>The following <code>Message</code> could result from parsing a row where <code>employee_first_name</code> was empty and <code>grade</code> was <code>null</code>:</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> Smith is a Software Engineer (null).</span></div></div><br></code></div></div>
|
||
<p>To troubleshoot missing or unexpected values, you can do the following:</p>
|
||
<ul>
|
||
<li>
|
||
<p>Make sure the variables in your template map to keys in the incoming <code>Data</code> or <code>DataFrame</code>.
|
||
To see the data being passed directly to the <strong>Parser</strong> component, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text-search" aria-hidden="true"><path d="M21 6H3"></path><path d="M10 12H3"></path><path d="M10 18H3"></path><circle cx="17" cy="15" r="3"></circle><path d="m21 19-1.9-1.9"></path></svg> <strong>Inspect output</strong> on the component that is sending data to the <strong>Parser</strong> component.</p>
|
||
</li>
|
||
<li>
|
||
<p>Check the source data for missing or incorrect values.
|
||
There are several ways you can address these inconsistencies:</p>
|
||
<ul>
|
||
<li>Rectify the source data directly.</li>
|
||
<li>Use other components to amend or filter anomalies before passing the data to the <strong>Parser</strong> component.
|
||
There are many components you can use for this depending on your goal, such as the <strong>Data Operations</strong>, <strong>Structured Output</strong>, and <strong>Smart Function</strong> components.</li>
|
||
<li>Enable the <strong>Parser</strong> component's <strong>Clean Data</strong> parameter to skip empty rows or lines.</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="python-interpreter">Python Interpreter<a href="#python-interpreter" class="hash-link" aria-label="Direct link to Python Interpreter" title="Direct link to Python Interpreter"></a></h2>
|
||
<p>This component allows you to execute Python code with imported packages.</p>
|
||
<p>The <strong>Python Interpreter</strong> component can only import packages that are already installed in your Langflow environment.
|
||
If you encounter an <code>ImportError</code> when trying to use a package, you need to install it first.</p>
|
||
<p>To install custom packages, see <a href="/install-custom-dependencies">Install custom dependencies</a>.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="use-the-python-interpreter-in-a-flow">Use the Python Interpreter in a flow<a href="#use-the-python-interpreter-in-a-flow" class="hash-link" aria-label="Direct link to Use the Python Interpreter in a flow" title="Direct link to Use the Python Interpreter in a flow"></a></h3>
|
||
<ol>
|
||
<li>To use this component in a flow, in the <strong>Global Imports</strong> field, add the packages you want to import as a comma-separated list, such as <code>math,pandas</code>.
|
||
At least one import is required.</li>
|
||
<li>In the <strong>Python Code</strong> field, enter the Python code you want to execute. Use <code>print()</code> to see the output.</li>
|
||
<li>Optional: Enable <strong>Tool Mode</strong>, and then connect the <strong>Python Interpreter</strong> component to an <strong>Agent</strong> component as a tool.
|
||
For example, connect a <strong>Python Interpreter</strong> component and a <a href="/components-helpers#calculator"><strong>Calculator</strong> component</a> as tools for an <strong>Agent</strong> component, and then test how it chooses different tools to solve math problems.
|
||
<img decoding="async" loading="lazy" alt="Python Interpreter and Calculator components connected to an Agent component" src="/assets/images/component-python-interpreter-1ef9e7dec643a216fd5e83c2139d09c9.png" width="3988" height="2928" class="img_ev3q"></li>
|
||
<li>Ask the agent an easier math question.
|
||
The <strong>Calculator</strong> tool can add, subtract, multiple, divide, or perform exponentiation.
|
||
The agent executes the <code>evaluate_expression</code> tool to correctly answer the question.</li>
|
||
</ol>
|
||
<p>Result:</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>Executed evaluate_expression</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>Input:</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> "expression": "2+5"</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>Output:</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> "result": "7"</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>}</span></div></div><br></code></div></div>
|
||
<ol start="5">
|
||
<li>Give the agent complete Python code.
|
||
This example creates a Pandas DataFrame table with the imported <code>pandas</code> packages, and returns the square root of the mean squares.</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">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span>import pandas as pd</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span>import math</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># Create a simple DataFrame</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span>df = pd.DataFrame({</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> 'numbers': [1, 2, 3, 4, 5],</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> 'squares': [x**2 for x in range(1, 6)]</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># Calculate the square root of the mean</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span>result = math.sqrt(df['squares'].mean())</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span>print(f"Square root of mean squares: {result}")</span></div></div><br></code></div></div>
|
||
<p>The agent correctly chooses the <code>run_python_repl</code> tool to solve the problem.</p>
|
||
<p>Result:</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">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span>Executed run_python_repl</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>Input:</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> "python_code": "import pandas as pd\nimport math\n\n# Create a simple DataFrame\ndf = pd.DataFrame({\n 'numbers': [1, 2, 3, 4, 5],\n 'squares': [x**2 for x in range(1, 6)]\n})\n\n# Calculate the square root of the mean\nresult = math.sqrt(df['squares'].mean())\nprint(f\"Square root of mean squares: {result}\")"</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>Output:</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> "result": "Square root of mean squares: 3.3166247903554"</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span>}</span></div></div><br></code></div></div>
|
||
<p>If you don't include the package imports in the chat, the agent can still create the table using <code>pd.DataFrame</code>, because the <code>pandas</code> package is imported globally by the <strong>Python Interpreter</strong> component in the <strong>Global Imports</strong> field.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="python-interpreter-parameters">Python Interpreter parameters<a href="#python-interpreter-parameters" class="hash-link" aria-label="Direct link to Python Interpreter parameters" title="Direct link to Python Interpreter parameters"></a></h3>
|
||
<table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>global_imports</td><td>String</td><td>Input parameter. A comma-separated list of modules to import globally, such as <code>math,pandas,numpy</code>.</td></tr><tr><td>python_code</td><td>Code</td><td>Input parameter. The Python code to execute. Only modules specified in Global Imports can be used.</td></tr><tr><td>results</td><td>Data</td><td>Output parameter. The output of the executed Python code, including any printed results or errors.</td></tr></tbody></table>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="save-file">Save File<a href="#save-file" class="hash-link" aria-label="Direct link to Save File" title="Direct link to Save File"></a></h2>
|
||
<p>The <strong>Save File</strong> component creates a file containing data produced by another component.
|
||
Several file formats are supported, and you can store files in <a href="/memory">Langflow storage</a> or the local file system.</p>
|
||
<p>To configure the <strong>Save File</strong> component and use it in a flow, do the following:</p>
|
||
<ol>
|
||
<li>
|
||
<p>Connect <a href="/data-types#dataframe"><code>DataFrame</code></a>, <a href="/data-types#data"><code>Data</code></a>, or <a href="/data-types#message"><code>Message</code></a> output from another component to the <strong>Save File</strong> component's <strong>Input</strong> port.</p>
|
||
<p>You can connect the same output to multiple <strong>Save File</strong> components if you want to create multiple files, save the data in different file formats, or save files to multiple locations.</p>
|
||
</li>
|
||
<li>
|
||
<p>In <strong>File Name</strong>, enter a file name and an optional path.</p>
|
||
<p>The <strong>File Name</strong> parameter controls where the file is saved.
|
||
It can contain a file name or an entire file path:</p>
|
||
<ul>
|
||
<li>
|
||
<p><strong>Default location</strong>: If you only provide a file name, then the file is stored in the Langflow data directory. For example,<code>~/Library/Caches/langflow/data</code> on macOS.</p>
|
||
</li>
|
||
<li>
|
||
<p><strong>Subdirectory</strong>: To store files in subdirectories, add the path to the <strong>File Name</strong> parameter.
|
||
If a given subdirectory doesn't already exist, Langflow automatically creates it.
|
||
For example, <code>files/my_file</code> creates <code>my_file</code> in <code>/data/files</code>, and it creates the <code>files</code> subdirectory if it doesn't already exist.</p>
|
||
</li>
|
||
<li>
|
||
<p><strong>Absolute or relative path</strong>: To store files elsewhere in your environment or local file storage, provide the absolute or relative path to the desired location.
|
||
For example, <code>~/Desktop/my_file</code> saves <code>my_file</code> to the desktop.</p>
|
||
</li>
|
||
</ul>
|
||
<p>Don't include an extension in the file name.
|
||
If you do, the extension is treated as part of the file name; it has no impact on the <strong>File Format</strong> parameter.</p>
|
||
</li>
|
||
<li>
|
||
<p>In the <a href="/concepts-components#component-menus">component's header menu</a>, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sliders-horizontal" aria-hidden="true"><line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line></svg> <strong>Controls</strong>, select the desired file format, and then click <strong>Close</strong>.</p>
|
||
<p>The available <strong>File Format</strong> options depend on the input data type:</p>
|
||
<ul>
|
||
<li>
|
||
<p><code>DataFrame</code> can be saved to CSV (default), Excel (requires <code>openpyxl</code> <a href="/install-custom-dependencies">custom dependency</a>), JSON (fallback default), or Markdown.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>Data</code> can be saved to CSV, Excel (requires <code>openpyxl</code> <a href="/install-custom-dependencies">custom dependency</a>), JSON (default), or Markdown.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>Message</code> can be saved to TXT, JSON (default), or Markdown.</p>
|
||
</li>
|
||
</ul>
|
||
<div class="theme-admonition theme-admonition-important admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>Overwrites allowed</div><div class="admonitionContent_BuS1"><p>If you have multiple <strong>Save File</strong> components, in one or more flows, with the same file name, path, and extension, the file contains the data from the most recent run only.
|
||
Langflow doesn't block overwrites if a matching file already exists.
|
||
To avoid unintended overwrites, use unique file names and paths.</p></div></div>
|
||
</li>
|
||
<li>
|
||
<p>To test the <strong>Save File</strong> component, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-play" aria-hidden="true"><polygon points="6 3 20 12 6 21 6 3"></polygon></svg> <strong>Run component</strong>, and then click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text-search" aria-hidden="true"><path d="M21 6H3"></path><path d="M10 12H3"></path><path d="M10 18H3"></path><circle cx="17" cy="15" r="3"></circle><path d="m21 19-1.9-1.9"></path></svg> <strong>Inspect output</strong> to get the filepath where the file was saved.</p>
|
||
<p>The component's literal output is a <code>Message</code> containing the original data type, the file name and extension, and the absolute filepath to the file based on the <strong>File Name</strong> parameter.
|
||
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>DataFrame saved successfully as 'my_file.csv' at /Users/user.name/Library/Caches/langflow/data/my_file.csv</span></div></div><br></code></div></div>
|
||
<p>If the <strong>File Name</strong> contains a subdirectory or other non-default path, this is reflected in the <code>Message</code> output.
|
||
For example, a CSV file with the file name <code>~/Desktop/my_file</code> could produce the following output:</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>DataFrame saved successfully as '/Users/user.name/Desktop/my_file.csv' at /Users/user.name/Desktop/my_file.csv</span></div></div><br></code></div></div>
|
||
</li>
|
||
<li>
|
||
<p>Optional: If you want to use the saved file in a flow, you must use an API call or another component to retrieve the file from the given filepath.</p>
|
||
</li>
|
||
</ol>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="smart-function">Smart Function<a href="#smart-function" class="hash-link" aria-label="Direct link to Smart Function" title="Direct link to Smart Function"></a></h2>
|
||
<p>In Langflow version 1.5, this component was renamed from <strong>Lambda Filter</strong> to <strong>Smart Function</strong>.</p>
|
||
<p>The <strong>Smart Function</strong> component uses an LLM to generate a Lambda function to filter or transform structured data based on natural language instructions.
|
||
You must connect this component to a <a href="/components-models"><strong>Language Model</strong> component</a>, which is used to generate a function based on the natural language instructions you provide in the <strong>Instructions</strong> parameter.
|
||
The LLM runs the function against the data input, and then outputs the results as <a href="/data-types#data"><code>Data</code></a>.</p>
|
||
<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>Provide brief, clear instructions, focusing on the desired outcome or specific actions, such as <code>Filter the data to only include items where the 'status' is 'active'</code>.
|
||
One sentence or less is preferred because end punctuation, like periods, can cause errors or unexpected behavior.</p><p>If you need to provide more details instructions that aren't directly relevant to the Lambda function, you can input them in the <strong>Language Model</strong> component's <strong>Input</strong> field or through a <strong>Prompt Template</strong> component.</p></div></div>
|
||
<p>The following example uses the <strong>API Request</strong> endpoint to pass JSON data from the <code>https://jsonplaceholder.typicode.com/users</code> endpoint to the <strong>Smart Function</strong> component.
|
||
Then, the <strong>Smart Function</strong> component passes the data and the instruction <code>extract emails</code> to the attached <strong>Language Model</strong> component.
|
||
From there, the LLM generates a filter function that extracts email addresses from the JSON data, returning the filtered data as chat output.</p>
|
||
<p><img decoding="async" loading="lazy" alt="A small flow using a Smart Function component to extract data from an API response." src="/assets/images/component-lambda-filter-76cd345c52fa41a59dcfac0205dc3068.png" width="4000" height="1796" class="img_ev3q"></p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="smart-function-parameters">Smart Function parameters<a href="#smart-function-parameters" class="hash-link" aria-label="Direct link to Smart Function parameters" title="Direct link to Smart Function parameters"></a></h3>
|
||
<p>Some parameters are hidden by default in the visual editor.
|
||
You can modify all parameters through the <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sliders-horizontal" aria-hidden="true"><line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line></svg> <strong>Controls</strong> in the <a href="/concepts-components#component-menus">component's header menu</a>.</p>
|
||
<table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>data</td><td>Data</td><td>Input parameter. The structured data to filter or transform using a Lambda function.</td></tr><tr><td>llm</td><td>Language Model</td><td>Input parameter. Connect <a href="/data-types#languagemodel"><code>LanguageModel</code></a> output from a <strong>Language Model</strong> component.</td></tr><tr><td>filter_instruction</td><td>Instructions</td><td>Input parameter. The natural language instructions for how to filter or transform the data. The LLM uses these instructions to create a Lambda function.</td></tr><tr><td>sample_size</td><td>Sample Size</td><td>Input parameter. For large datasets, the number of characters to sample from the dataset head and tail. Only applied if the dataset meets or exceeds <code>max_size</code>. Default: <code>1000</code>.</td></tr><tr><td>max_size</td><td>Max Size</td><td>Input parameter. The number of characters for the dataset to be considered large, which triggers sampling by the <code>sample_size</code> value. Default: <code>30000</code>.</td></tr></tbody></table>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="split-text">Split Text<a href="#split-text" class="hash-link" aria-label="Direct link to Split Text" title="Direct link to Split Text"></a></h2>
|
||
<p>The <strong>Split Text</strong> component splits data into chunks based on parameters like chunk size and separator.
|
||
It is often used to chunk data to be tokenized and embedded into vector databases.
|
||
For examples, see <a href="/components-vector-stores#use-vector-store-components-in-a-flow">Use Vector Store components in a flow</a>, <a href="/components-embedding-models#use-embedding-model-components-in-a-flow">Use Embedding Model components in a flow</a>, and <a href="/chat-with-rag">Create a Vector RAG chatbot</a>.</p>
|
||
<p><img decoding="async" loading="lazy" alt="An embedding generation flow that uses a Split Text component to chunk data." src="/assets/images/component-split-text-fec2b1abb28e0852c8a172bbeb164b2c.png" width="4000" height="2766" class="img_ev3q"></p>
|
||
<p>The component accepts <code>Message</code>, <code>Data</code>, or <code>DataFrame</code>, and then outputs either <strong>Chunks</strong> or <strong>DataFrame</strong>.
|
||
The <strong>Chunks</strong> output returns a list of <a href="/data-types#data"><code>Data</code></a> objects containing individual text chunks.
|
||
The <strong>DataFrame</strong> output returns the list of chunks as a structured <a href="/data-types#dataframe"><code>DataFrame</code></a> with additional <code>text</code> and <code>metadata</code> columns.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="split-text-parameters">Split Text parameters<a href="#split-text-parameters" class="hash-link" aria-label="Direct link to Split Text parameters" title="Direct link to Split Text parameters"></a></h3>
|
||
<p>The <strong>Split Text</strong> component's parameters control how the text is split into chunks, specifically the <code>chunk_size</code>, <code>chunk_overlap</code>, and <code>separator</code> parameters.</p>
|
||
<p>To test the chunking behavior, add a <strong>Text Input</strong> or <strong>File</strong> component with some sample data to chunk, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-play" aria-hidden="true"><polygon points="6 3 20 12 6 21 6 3"></polygon></svg> <strong>Run component</strong> on the <strong>Split Text</strong> component, and then click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text-search" aria-hidden="true"><path d="M21 6H3"></path><path d="M10 12H3"></path><path d="M10 18H3"></path><circle cx="17" cy="15" r="3"></circle><path d="m21 19-1.9-1.9"></path></svg> <strong>Inspect output</strong> to view the list of chunks and their metadata. The <strong>text</strong> column contains the actual text chunks created from your chunking settings.
|
||
If the chunks aren't split as you expect, adjust the parameters, rerun the component, and then inspect the new output.</p>
|
||
<p>Some parameters are hidden by default in the visual editor.
|
||
You can modify all parameters through the <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sliders-horizontal" aria-hidden="true"><line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line></svg> <strong>Controls</strong> in the <a href="/concepts-components#component-menus">component's header menu</a>.</p>
|
||
<table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>data_inputs</td><td>Input</td><td>Input parameter. The data to split. Input must be in <code>Message</code>, <code>Data</code>, or <code>DataFrame</code> format.</td></tr><tr><td>chunk_overlap</td><td>Chunk Overlap</td><td>Input parameter. The number of characters to overlap between chunks. This helps maintain context across chunks. When a separator is encountered, the overlap is applied at the point of the separator so that the subsequent chunk contains the last <em>n</em> characters of the preceding chunk. Default: <code>200</code>.</td></tr><tr><td>chunk_size</td><td>Chunk Size</td><td>Input parameter. The target length for each chunk after splitting. The data is first split by separator, and then chunks smaller than the <code>chunk_size</code> are merged up to this limit. However, if the initial separator split produces any chunks larger than the <code>chunk_size</code>, those chunks are neither further subdivided nor combined with any smaller chunks; these chunks will be output as-is even though they exceed the <code>chunk_size</code>. Default: <code>1000</code>. See <a href="#chunk-size">Tokenization errors due to chunk size</a> for important considerations.</td></tr><tr><td>separator</td><td>Separator</td><td>Input parameter. A string defining a character to split on, such as <code>\n</code> to split on new line characters, <code>\n\n</code> to split at paragraph breaks, or <code>},</code> to split at the end of JSON objects. You can directly provide the separator string, or pass a separator string from another component as <code>Message</code> input.</td></tr><tr><td>text_key</td><td>Text Key</td><td>Input parameter. The key to use for the text column that is extracted from the input and then split. Default: <code>text</code>.</td></tr><tr><td>keep_separator</td><td>Keep Separator</td><td>Input parameter. Select how to handle separators in output chunks. If False, separators are omitted from output chunks. Options include <code>False</code> (remove separators), <code>True</code> (keep separators in chunks without preference for placement), <code>Start</code> (place separators at the beginning of chunks), or <code>End</code> (place separators at the end of chunks). Default: <code>False</code>.</td></tr></tbody></table>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="chunk-size">Tokenization errors due to chunk size<a href="#chunk-size" class="hash-link" aria-label="Direct link to Tokenization errors due to chunk size" title="Direct link to Tokenization errors due to chunk size"></a></h3>
|
||
<p>When using <strong>Split Text</strong> with embedding models (especially NVIDIA models like <code>nvidia/nv-embed-v1</code>), you may need to use smaller chunk sizes (<code>500</code> or less) even though the model supports larger token limits.
|
||
The <strong>Split Text</strong> component doesn't always enforce the exact chunk size you set, and individual chunks may exceed your specified limit.
|
||
If you encounter tokenization errors, modify your text splitting strategy by reducing the chunk size, changing the overlap length, or using a more common separator.
|
||
Then, test your configuration by running the flow and inspecting the component's output.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="other-text-splitters">Other text splitters<a href="#other-text-splitters" class="hash-link" aria-label="Direct link to Other text splitters" title="Direct link to Other text splitters"></a></h3>
|
||
<p>See <a href="/bundles-langchain#text-splitters">LangChain text splitter components</a>.</p>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="structured-output">Structured Output<a href="#structured-output" class="hash-link" aria-label="Direct link to Structured Output" title="Direct link to Structured Output"></a></h2>
|
||
<p>The <strong>Structured Output</strong> component uses an LLM to transform any input into structured data (<code>Data</code> or <code>DataFrame</code>) using natural language formatting instructions and an output schema definition.
|
||
For example, you can extract specific details from documents, like email messages or scientific papers.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="use-the-structured-output-component-in-a-flow">Use the Structured Output component in a flow<a href="#use-the-structured-output-component-in-a-flow" class="hash-link" aria-label="Direct link to Use the Structured Output component in a flow" title="Direct link to Use the Structured Output component in a flow"></a></h3>
|
||
<p>To use the <strong>Structured Output</strong> component in a flow, do the following:</p>
|
||
<ol>
|
||
<li>
|
||
<p>Provide an <strong>Input Message</strong>, which is the source material from which you want to extract structured data.
|
||
This can come from practically any component, but it is typically a <strong>Chat Input</strong>, <strong>File</strong>, or other component that provides some unstructured or semi-structured input.</p>
|
||
<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>Not all source material has to become structured output.
|
||
The power of the <strong>Structured Output</strong> component is that you can specify the information you want to extract, even if that data isn't explicitly labeled or an exact keyword match.
|
||
Then, the LLM can use your instructions to analyze the source material, extract the relevant data, and format it according to your specifications.
|
||
Any irrelevant source material isn't included in the structured output.</p></div></div>
|
||
</li>
|
||
<li>
|
||
<p>Define <strong>Format Instructions</strong> and an <strong>Output Schema</strong> to specify the data to extract from the source material and how to structure it in the final <code>Data</code> or <code>DataFrame</code> output.</p>
|
||
<p>The instructions are a prompt that tell the LLM what data to extract, how to format it, how to handle exceptions, and any other instructions relevant to preparing the structured data.</p>
|
||
<p>The schema is a table that defines the fields (keys) and data types to organize the data extracted by the LLM into a structured <code>Data</code> or <code>DataFrame</code> object.
|
||
For more information, see <a href="#output-schema-options">Output Schema options</a></p>
|
||
</li>
|
||
<li>
|
||
<p>Attach a <a href="/components-models"><strong>Language Model</strong> component</a> that is set to emit <a href="/data-types#languagemodel"><code>LanguageModel</code></a> output.</p>
|
||
<p>The LLM uses the <strong>Input Message</strong> and <strong>Format Instructions</strong> from the <strong>Structured Output</strong> component to extract specific pieces of data from the input text.
|
||
The output schema is applied to the model's response to produce the final <code>Data</code> or <code>DataFrame</code> structured object.</p>
|
||
</li>
|
||
<li>
|
||
<p>Optional: Typically, the structured output is passed to downstream components that use the extracted data for other processes, such as the <strong>Parser</strong> or <strong>Data Operations</strong> components.</p>
|
||
</li>
|
||
</ol>
|
||
<p><img decoding="async" loading="lazy" alt="A basic flow with Structured Output, Language Model, Type Convert, and Chat Input and Output components." src="/assets/images/component-structured-output-23458b0d29eed6d092b557c7aaf6ab2c.png" width="4000" height="1724" class="img_ev3q"></p>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Structured Output example: Financial Report Parser template</summary><div><div class="collapsibleContent_i85q"><p>The <strong>Financial Report Parser</strong> template provides an example of how the <strong>Structured Output</strong> component can be used to extract structured data from unstructured text.</p><p>The template's <strong>Structured Output</strong> component has the following configuration:</p><ul>
|
||
<li>
|
||
<p>The <strong>Input Message</strong> comes from a <strong>Chat Input</strong> component that is preloaded with quotes from sample financial reports</p>
|
||
</li>
|
||
<li>
|
||
<p>The <strong>Format Instructions</strong> are as follows:</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>You are an AI that extracts structured JSON objects from unstructured text.</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>Use a predefined schema with expected types (str, int, float, bool, dict).</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>Extract ALL relevant instances that match the schema - if multiple patterns exist, capture them all.</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>Fill missing or ambiguous values with defaults: null for missing values.</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>Remove exact duplicates but keep variations that have different field values.</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>Always return valid JSON in the expected format, never throw errors.</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>If multiple objects can be extracted, return them all in the structured format.</span></div></div><br></code></div></div>
|
||
</li>
|
||
<li>
|
||
<p>The <strong>Output Schema</strong> includes keys for <code>EBITDA</code>, <code>NET_INCOME</code>, and <code>GROSS_PROFIT</code>.</p>
|
||
</li>
|
||
</ul><p>The structured <code>Data</code> object is passed to a <strong>Parser</strong> component that produces a text string by mapping the schema keys to variables in the parsing template:</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>EBITDA: {EBITDA} , Net Income: {NET_INCOME} , GROSS_PROFIT: {GROSS_PROFIT}</span></div></div><br></code></div></div><p>When printed to the <strong>Playground</strong>, the resulting <code>Message</code> replaces the variables with the actual values extracted by the <strong>Structured Output</strong> 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>EBITDA: 900 million , Net Income: 500 million , GROSS_PROFIT: 1.2 billion</span></div></div><br></code></div></div></div></div></details>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="structured-output-parameters">Structured Output parameters<a href="#structured-output-parameters" class="hash-link" aria-label="Direct link to Structured Output parameters" title="Direct link to Structured Output parameters"></a></h3>
|
||
<p>Some parameters are hidden by default in the visual editor.
|
||
You can modify all parameters through the <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sliders-horizontal" aria-hidden="true"><line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line></svg> <strong>Controls</strong> in the <a href="/concepts-components#component-menus">component's header menu</a>.</p>
|
||
<table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>Language Model (<code>llm</code>)</td><td><code>LanguageModel</code></td><td>Input parameter. The <a href="/data-types#languagemodel"><code>LanguageModel</code></a> output from a <strong>Language Model</strong> component that defines the LLM to use to analyze, extract, and prepare the structured output.</td></tr><tr><td>Input Message (<code>input_value</code>)</td><td>String</td><td>Input parameter. The input message containing source material for extraction.</td></tr><tr><td>Format Instructions (<code>system_prompt</code>)</td><td>String</td><td>Input parameter. The instructions to the language model for extracting and formatting the output.</td></tr><tr><td>Schema Name (<code>schema_name</code>)</td><td>String</td><td>Input parameter. An optional title for the <strong>Output Schema</strong>.</td></tr><tr><td>Output Schema (<code>output_schema</code>)</td><td>Table</td><td>Input parameter. A table describing the schema of the desired structured output, ultimately determining the content of the <code>Data</code> or <code>DataFrame</code> output. See <a href="#output-schema-options">Output Schema options</a>.</td></tr><tr><td>Structured Output (<code>structured_output</code>)</td><td><code>Data</code> or <code>DataFrame</code></td><td>Output parameter. The final structured output produced by the component. Near the component's output port, you can select the output data type as either <strong>Structured Output Data</strong> or <strong>Structured Output DataFrame</strong>. The specific content and structure of the output depends on the input parameters.</td></tr></tbody></table>
|
||
<h4 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="output-schema-options">Output Schema options<a href="#output-schema-options" class="hash-link" aria-label="Direct link to Output Schema options" title="Direct link to Output Schema options"></a></h4>
|
||
<p>After the LLM extracts the relevant data from the <strong>Input Message</strong> and <strong>Format Instructions</strong>, the data is organized according to the <strong>Output Schema</strong>.</p>
|
||
<p>The schema is a table that defines the fields (keys) and data types for the final <code>Data</code> or <code>DataFrame</code> output from the <strong>Structured Output</strong> component.</p>
|
||
<p>The default schema is a single <code>field</code> string.</p>
|
||
<p>To add a key to the schema, click <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus" aria-hidden="true"><path d="M5 12h14"></path><path d="M12 5v14"></path></svg> <strong>Add a new row</strong>, and then edit each column to define the schema:</p>
|
||
<ul>
|
||
<li>
|
||
<p><strong>Name</strong>: The name of the output field. Typically a specific key for which you want to extract a value.</p>
|
||
<p>You can reference these keys as variables in downstream components, such as a <strong>Parser</strong> component's template.
|
||
For example, the schema key <code>NET_INCOME</code> could be referenced by the variable <code>{NET_INCOME}</code>.</p>
|
||
</li>
|
||
<li>
|
||
<p><strong>Description</strong>: An optional metadata description of the field's contents and purpose.</p>
|
||
</li>
|
||
<li>
|
||
<p><strong>Type</strong>: The data type of the value stored in the field.
|
||
Supported types are <code>str</code> (default), <code>int</code>, <code>float</code>, <code>bool</code>, and <code>dict</code>.</p>
|
||
</li>
|
||
<li>
|
||
<p><strong>As List</strong>: Enable this setting if you want the field to contain a list of values rather than a single value.</p>
|
||
</li>
|
||
</ul>
|
||
<p>For simple schemas, you might only extract a few <code>string</code> or <code>int</code> fields.
|
||
For more complex schemas with lists and dictionaries, it might help to refer to the <code>Data</code> and <code>DataFrame</code> structures and attributes, as described in <a href="/data-types">Langflow data types</a>.
|
||
You can also emit a rough <code>Data</code> or <code>DataFrame</code>, and then use downstream components for further refinement, such as a <strong>Data Operations</strong> component.</p>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="type-convert">Type Convert<a href="#type-convert" class="hash-link" aria-label="Direct link to Type Convert" title="Direct link to Type Convert"></a></h2>
|
||
<p>The <strong>Type Convert</strong> component converts data from one type to another.
|
||
It supports <code>Data</code>, <code>DataFrame</code>, and <code>Message</code> data types.</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">Data</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">DataFrame</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Message</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><p>A <code>Data</code> object is a structured object that contains a primary <code>text</code> key and other key-value pairs:</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>"data": {</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "text": "User Profile",</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "name": "Charlie Lastname",</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "age": 28,</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "email": "charlie.lastname@example.com"</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>},</span></div></div><br></code></div></div><p>The larger context associated with a component's <code>data</code> dictionary also identifies which key is the primary <code>text_key</code>, and it can provide an optional default value if the primary key isn't specified.
|
||
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>{</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "text_key": "text",</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "data": {</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "text": "User Profile",</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "name": "Charlie Lastname",</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "age": 28,</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span> "email": "charlie.lastname@example.com"</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> "default_value": ""</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>}</span></div></div><br></code></div></div></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>A <code>DataFrame</code> is an array that represents a tabular data structure with rows and columns.</p><p>It consists of a list (array) of dictionary objects, where each dictionary represents a row.
|
||
Each key in the dictionaries corresponds to a column name.
|
||
For example, the following <code>DataFrame</code> contains two rows with columns for <code>name</code>, <code>age</code>, and <code>email</code>:</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">_<!-- -->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> "name": "Charlie Lastname",</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> "age": 28,</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> "email": "charlie.lastname@example.com"</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> "name": "Bobby Othername",</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> "age": 25,</span></div></div><div><span class="ch-code-line-number">_<!-- -->12</span><div style="display:inline-block;margin-left:16px"><span> "email": "bobby.othername@example.com"</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><br></code></div></div></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>A <code>Message</code> is primarily for passing a <code>text</code> string, such as<code>"Name: Charlie Lastname, Age: 28, Email: charlie.lastname@example.com"</code>.
|
||
However, the entire <code>Message</code> object can include metadata about the message, particularly when used as chat input or output.</p></div></div></div>
|
||
<p>For more information, see <a href="/data-types">Langflow data types</a>.</p>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="use-the-type-convert-component-in-a-flow">Use the Type Convert component in a flow<a href="#use-the-type-convert-component-in-a-flow" class="hash-link" aria-label="Direct link to Use the Type Convert component in a flow" title="Direct link to Use the Type Convert component in a flow"></a></h3>
|
||
<p>The <strong>Type Convert</strong> component is typically used to transform data into a format required by a downstream component.
|
||
For example, if a component outputs a <code>Message</code>, but the following component requires <code>Data</code>, then you can use the <strong>Type Convert</strong> component to reformat the <code>Message</code> as <code>Data</code> before passing it to the downstream component.</p>
|
||
<p>The following example uses the <strong>Type Convert</strong> component to convert the <code>DataFrame</code> output from a <strong>Web Search</strong> component into <code>Message</code> data that is passed as text input for an LLM:</p>
|
||
<ol>
|
||
<li>
|
||
<p>Create a flow based on the <strong>Basic prompting</strong> template.</p>
|
||
</li>
|
||
<li>
|
||
<p>Add a <strong>Web Search</strong> component to the flow, and then enter a search query, such as <code>environmental news</code>.</p>
|
||
</li>
|
||
<li>
|
||
<p>In the <strong>Prompt Template</strong> component, replace the contents of the <strong>Template</strong> field with the following text:</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>Answer the user's question using the {context}</span></div></div><br></code></div></div>
|
||
<p>The curly braces define a <a href="/components-prompts#define-variables-in-prompts">prompt variable</a> that becomes an input field on the <strong>Prompt Template</strong> component.
|
||
In this example, you will use the <strong>context</strong> field to pass the search results into the template, as explained in the next steps.</p>
|
||
</li>
|
||
<li>
|
||
<p>Add a <strong>Type Convert</strong> component to the flow, and then set the <strong>Output Type</strong> to <strong>Message</strong>.</p>
|
||
<p>Because the <strong>Web Search</strong> component's <code>DataFrame</code> output is incompatible with the <strong>context</strong> variable's <code>Message</code> input, you must use the <strong>Type Convert</strong> component to change the <code>DataFrame</code> to a <code>Message</code> in order to pass the search results to the <strong>Prompt Template</strong> component.</p>
|
||
</li>
|
||
<li>
|
||
<p>Connect the additional components to the rest of the flow:</p>
|
||
<ul>
|
||
<li>Connect the <strong>Web Search</strong> component's output to the <strong>Type Convert</strong> component's input.</li>
|
||
<li>Connect the <strong>Type Convert</strong> component's output to the <strong>Prompt Template</strong> component's <strong>context</strong> input.</li>
|
||
</ul>
|
||
<p><img decoding="async" loading="lazy" alt="Convert web search output to text input" src="/assets/images/component-type-convert-and-web-search-1eef7b9a7c1a243f4a08d9717728d0e1.png" width="4000" height="1826" class="img_ev3q"></p>
|
||
</li>
|
||
<li>
|
||
<p>In the <strong>Language Model</strong> component, add your OpenAI API key.</p>
|
||
<p>If you want to use a different provider or model, edit the <strong>Model Provider</strong>, <strong>Model Name</strong>, and <strong>API Key</strong> fields accordingly.</p>
|
||
</li>
|
||
<li>
|
||
<p>Click <strong>Playground</strong>, and then ask something relevant to your search query, such as <code>latest news</code> or <code>what's the latest research on the environment?</code>.</p>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Result</summary><div><div class="collapsibleContent_i85q"><p>The LLM uses the search results context, your chat message, and it's built-in training data to respond to your question.
|
||
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>Here are some of the latest news articles related to the environment:</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>Ozone Pollution and Global Warming: A recent study highlights that ozone pollution is a significant global environmental concern, threatening human health and crop production while exacerbating global warming. Read more</span></div></div><div><span class="ch-code-line-number">_<!-- -->10</span><div style="display:inline-block;margin-left:16px"><span>...</span></div></div><br></code></div></div></div></div></details>
|
||
</li>
|
||
</ol>
|
||
<h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="type-convert-parameters">Type Convert parameters<a href="#type-convert-parameters" class="hash-link" aria-label="Direct link to Type Convert parameters" title="Direct link to Type Convert parameters"></a></h3>
|
||
<table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>input_data</td><td>Input Data</td><td>Input parameter. The data to convert. Accepts <code>Data</code>, <code>DataFrame</code>, or <code>Message</code> input.</td></tr><tr><td>output_type</td><td>Output Type</td><td>Input parameter. The desired output type, as one of <strong>Data</strong>, <strong>DataFrame</strong> or <strong>Message</strong>.</td></tr><tr><td>output</td><td>Output</td><td>Output parameter. The converted data in the specified format. The output port changes depending on the selected <strong>Output Type</strong>.</td></tr></tbody></table>
|
||
<h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="legacy-processing-components">Legacy Processing components<a href="#legacy-processing-components" class="hash-link" aria-label="Direct link to Legacy Processing components" title="Direct link to Legacy Processing components"></a></h2>
|
||
<p>The following <strong>Processing</strong> components are legacy components.
|
||
You can still use them in your flows, but they are no longer supported and can be removed in a future release.</p>
|
||
<p>Replace these components with suggested alternatives as soon as possible.</p>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Alter Metadata</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#data-operations"><strong>Data Operations</strong> component</a>.</p><p>This component modifies metadata of input objects. It can add new metadata, update existing metadata, and remove specified metadata fields. The component works with both <code>Message</code> and <code>Data</code> objects, and can also create a new <code>Data</code> object from user-provided text.</p><p>It accepts the following parameters:</p><table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>input_value</td><td>Input</td><td>Input parameter. Objects to which Metadata should be added.</td></tr><tr><td>text_in</td><td>User Text</td><td>Input parameter. Text input; the value is contained in the 'text' attribute of the <code>Data</code> object. Empty text entries are ignored.</td></tr><tr><td>metadata</td><td>Metadata</td><td>Input parameter. Metadata to add to each object.</td></tr><tr><td>remove_fields</td><td>Fields to Remove</td><td>Input parameter. Metadata fields to remove.</td></tr><tr><td>data</td><td>Data</td><td>Output parameter. List of Input objects, each with added metadata.</td></tr></tbody></table></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Combine Data/Merge Data</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#data-operations"><strong>Data Operations</strong> component</a> or the <a href="/components-logic#loop"><strong>Loop</strong> component</a>.</p><p>This component combines multiple data sources into a single unified <code>Data</code> object.</p><p>The component iterates through a list of <code>Data</code> objects, merging them into a single <code>Data</code> object (<code>merged_data</code>).
|
||
If the input list is empty, it returns an empty data object.
|
||
If there's only one input data object, it returns that object unchanged.</p><p>The merging process uses the addition operator to combine data objects.</p></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Combine Text</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#data-operations"><strong>Data Operations</strong> component</a>.</p><p>This component concatenates two text inputs into a single text chunk using a specified delimiter, outputting a <code>Message</code> object with the combined text.</p></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Create Data</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#data-operations"><strong>Data Operations</strong> component</a>.</p><p>This component dynamically creates a <code>Data</code> object with a specified number of fields and a text key.</p><p>It accepts the following parameters:</p><table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>number_of_fields</td><td>Number of Fields</td><td>Input parameter. The number of fields to be added to the record.</td></tr><tr><td>text_key</td><td>Text Key</td><td>Input parameter. Key that identifies the field to be used as the text content.</td></tr><tr><td>text_key_validator</td><td>Text Key Validator</td><td>Input parameter. If enabled, checks if the given <code>Text Key</code> is present in the given <code>Data</code>.</td></tr></tbody></table></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Extract Key</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#data-operations"><strong>Data Operations</strong> component</a>.</p><p>This component extracts a specific key from a <code>Data</code> object and returns the value associated with that key.</p></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Data to DataFrame/Data to Message</summary><div><div class="collapsibleContent_i85q"><p>Replace these legacy components with newer <strong>Processing</strong> components, such as the <a href="#data-operations"><strong>Data Operations</strong> component</a> and <a href="#type-convert"><strong>Type Convert</strong> component</a>.</p><p>These components converted one or more <code>Data</code> objects into a <code>DataFrame</code> or <code>Message</code> object.</p><p>For the <strong>Data to DataFrame</strong> component, each <code>Data</code> object corresponds to one row in the resulting <code>DataFrame</code>.
|
||
Fields from the <code>.data</code> attribute become columns, and the <code>.text</code> field (if present) is placed in a <code>text</code> column.</p></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Filter Data</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#data-operations"><strong>Data Operations</strong> component</a>.</p><p>This component filters a <code>Data</code> object based on a list of keys (<code>filter_criteria</code>), returning a new <code>Data</code> object (<code>filtered_data</code>) that contains only the key-value pairs that match the filter criteria.</p></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Filter Values</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#data-operations"><strong>Data Operations</strong> component</a>.</p><p>The Filter values component filters a list of data items based on a specified key, filter value, and comparison operator.</p><p>It accepts the following parameters:</p><table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>input_data</td><td>Input data</td><td>Input parameter. The list of data items to filter.</td></tr><tr><td>filter_key</td><td>Filter Key</td><td>Input parameter. The key to filter on.</td></tr><tr><td>filter_value</td><td>Filter Value</td><td>Input parameter. The value to filter by.</td></tr><tr><td>operator</td><td>Comparison Operator</td><td>Input parameter. The operator to apply for comparing the values.</td></tr><tr><td>filtered_data</td><td>Filtered data</td><td>Output parameter. The resulting list of filtered data items.</td></tr></tbody></table></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>JSON Cleaner</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#parser"><strong>Parser</strong> component</a>.</p><p>This component cleans JSON strings to ensure they are fully compliant with the JSON specification.</p><p>It accepts the following parameters:</p><table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>json_str</td><td>JSON String</td><td>Input parameter. The JSON string to be cleaned. This can be a raw, potentially malformed JSON string produced by language models or other sources that may not fully comply with JSON specifications.</td></tr><tr><td>remove_control_chars</td><td>Remove Control Characters</td><td>Input parameter. If set to True, this option removes control characters (ASCII characters 0-31 and 127) from the JSON string. This can help eliminate invisible characters that might cause parsing issues or make the JSON invalid.</td></tr><tr><td>normalize_unicode</td><td>Normalize Unicode</td><td>Input parameter. When enabled, this option normalizes Unicode characters in the JSON string to their canonical composition form (NFC). This ensures consistent representation of Unicode characters across different systems and prevents potential issues with character encoding.</td></tr><tr><td>validate_json</td><td>Validate JSON</td><td>Input parameter. If set to True, this option attempts to parse the JSON string to ensure it is well-formed before applying the final repair operation. It raises a ValueError if the JSON is invalid, allowing for early detection of major structural issues in the JSON.</td></tr><tr><td>output</td><td>Cleaned JSON String</td><td>Output parameter. The resulting cleaned, repaired, and validated JSON string that fully complies with the JSON specification.</td></tr></tbody></table></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Message to Data</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#type-convert"><strong>Type Convert</strong> component</a>.</p><p>This component converts <code>Message</code> objects to <code>Data</code> objects.</p></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Parse DataFrame</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#dataframe-operations"><strong>DataFrame Operations</strong> component</a> or <a href="#parser"><strong>Parser</strong> component</a>.</p><p>This component converts <code>DataFrame</code> objects into plain text using templates.</p><p>It accepts the following parameters:</p><table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>df</td><td>DataFrame</td><td>Input parameter. The DataFrame to convert to text rows.</td></tr><tr><td>template</td><td>Template</td><td>Input parameter. Template for formatting (use <code>{column_name}</code> placeholders).</td></tr><tr><td>sep</td><td>Separator</td><td>Input parameter. String to join rows in output.</td></tr><tr><td>text</td><td>Text</td><td>Output parameter. All rows combined into single text.</td></tr></tbody></table></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Parse JSON</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#parser"><strong>Parser</strong> component</a>.</p><p>This component converts and extracts JSON fields in <code>Message</code> and <code>Data</code> objects using JQ queries, then returns <code>filtered_data</code>, which is a list of <code>Data</code> objects.</p></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Python REPL</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#python-interpreter"><strong>Python Interpreter</strong> component</a> or another processing or logic component.</p><p>This component creates a Python REPL (Read-Eval-Print Loop) tool for executing Python code.</p><p>It accepts the following parameters:</p><table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>name</td><td>String</td><td>Input parameter. The name of the tool. Default: <code>python_repl</code>.</td></tr><tr><td>description</td><td>String</td><td>Input parameter. A description of the tool's functionality.</td></tr><tr><td>global_imports</td><td>List[String]</td><td>Input parameter. A list of modules to import globally. Default: <code>math</code>.</td></tr><tr><td>tool</td><td>Tool</td><td>Output parameter. A Python REPL tool for use in LangChain.</td></tr></tbody></table></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Python Code Structured</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#python-interpreter"><strong>Python Interpreter</strong> component</a> or another processing or logic component.</p><p>This component creates a structured tool from Python code using a dataclass.</p><p>The component dynamically updates its configuration based on the provided Python code, allowing for custom function arguments and descriptions.</p><p>It accepts the following parameters:</p><table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>tool_code</td><td>String</td><td>Input parameter. The Python code for the tool's dataclass.</td></tr><tr><td>tool_name</td><td>String</td><td>Input parameter. The name of the tool.</td></tr><tr><td>tool_description</td><td>String</td><td>Input parameter. The description of the tool.</td></tr><tr><td>return_direct</td><td>Boolean</td><td>Input parameter. Whether to return the function output directly.</td></tr><tr><td>tool_function</td><td>String</td><td>Input parameter. The selected function for the tool.</td></tr><tr><td>global_variables</td><td>Dict</td><td>Input parameter. Global variables or data for the tool.</td></tr><tr><td>result_tool</td><td>Tool</td><td>Output parameter. A structured tool created from the Python code.</td></tr></tbody></table></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Regex Extractor</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#parser"><strong>Parser</strong> component</a>.</p><p>This component extracts patterns in text using regular expressions. It can be used to find and extract specific patterns or information in text.</p></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Select Data</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#data-operations"><strong>Data Operations</strong> component</a>.</p><p>This component selects a single <code>Data</code> object from a list.</p><p>It accepts the following parameters:</p><table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>data_list</td><td>Data List</td><td>Input parameter. List of data to select from</td></tr><tr><td>data_index</td><td>Data Index</td><td>Input parameter. Index of the data to select</td></tr><tr><td>selected_data</td><td>Selected Data</td><td>Output parameter. The selected <code>Data</code> object.</td></tr></tbody></table></div></div></details>
|
||
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Update Data</summary><div><div class="collapsibleContent_i85q"><p>Replace this legacy component with the <a href="#data-operations"><strong>Data Operations</strong> component</a>.</p><p>This component dynamically updates or appends data with specified fields.</p><p>It accepts the following parameters:</p><table><thead><tr><th>Name</th><th>Display Name</th><th>Info</th></tr></thead><tbody><tr><td>old_data</td><td>Data</td><td>Input parameter. The records to update.</td></tr><tr><td>number_of_fields</td><td>Number of Fields</td><td>Input parameter. The number of fields to add. The maximum is 15.</td></tr><tr><td>text_key</td><td>Text Key</td><td>Input parameter. The key for text content.</td></tr><tr><td>text_key_validator</td><td>Text Key Validator</td><td>Input parameter. Validates the text key presence.</td></tr><tr><td>data</td><td>Data</td><td>Output parameter. The updated Data objects.</td></tr></tbody></table></div></div></details></div></article><nav class="docusaurus-mt-lg pagination-nav" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/components-vector-stores"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Vector Stores</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/components-prompts"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Prompt Template</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="#prompt-template" class="table-of-contents__link toc-highlight">Prompt Template</a></li><li><a href="#batch-run" class="table-of-contents__link toc-highlight">Batch Run</a><ul><li><a href="#use-the-batch-run-component-in-a-flow" class="table-of-contents__link toc-highlight">Use the Batch Run component in a flow</a></li><li><a href="#batch-run-parameters" class="table-of-contents__link toc-highlight">Batch Run parameters</a></li></ul></li><li><a href="#data-operations" class="table-of-contents__link toc-highlight">Data Operations</a><ul><li><a href="#use-the-data-operations-component-in-a-flow" class="table-of-contents__link toc-highlight">Use the Data Operations component in a flow</a></li><li><a href="#data-operations-parameters" class="table-of-contents__link toc-highlight">Data Operations parameters</a></li></ul></li><li><a href="#dataframe-operations" class="table-of-contents__link toc-highlight">DataFrame Operations</a><ul><li><a href="#use-the-dataframe-operations-component-in-a-flow" class="table-of-contents__link toc-highlight">Use the DataFrame Operations component in a flow</a></li><li><a href="#dataframe-operations-parameters" class="table-of-contents__link toc-highlight">DataFrame Operations parameters</a></li></ul></li><li><a href="#llm-router" class="table-of-contents__link toc-highlight">LLM Router</a><ul><li><a href="#llm-router-parameters" class="table-of-contents__link toc-highlight">LLM Router parameters</a></li><li><a href="#llm-router-outputs" class="table-of-contents__link toc-highlight">LLM Router outputs</a></li></ul></li><li><a href="#parser" class="table-of-contents__link toc-highlight">Parser</a><ul><li><a href="#parsing-modes" class="table-of-contents__link toc-highlight">Parsing modes</a></li><li><a href="#test-and-troubleshoot-parsed-text" class="table-of-contents__link toc-highlight">Test and troubleshoot parsed text</a></li></ul></li><li><a href="#python-interpreter" class="table-of-contents__link toc-highlight">Python Interpreter</a><ul><li><a href="#use-the-python-interpreter-in-a-flow" class="table-of-contents__link toc-highlight">Use the Python Interpreter in a flow</a></li><li><a href="#python-interpreter-parameters" class="table-of-contents__link toc-highlight">Python Interpreter parameters</a></li></ul></li><li><a href="#save-file" class="table-of-contents__link toc-highlight">Save File</a></li><li><a href="#smart-function" class="table-of-contents__link toc-highlight">Smart Function</a><ul><li><a href="#smart-function-parameters" class="table-of-contents__link toc-highlight">Smart Function parameters</a></li></ul></li><li><a href="#split-text" class="table-of-contents__link toc-highlight">Split Text</a><ul><li><a href="#split-text-parameters" class="table-of-contents__link toc-highlight">Split Text parameters</a></li><li><a href="#chunk-size" class="table-of-contents__link toc-highlight">Tokenization errors due to chunk size</a></li><li><a href="#other-text-splitters" class="table-of-contents__link toc-highlight">Other text splitters</a></li></ul></li><li><a href="#structured-output" class="table-of-contents__link toc-highlight">Structured Output</a><ul><li><a href="#use-the-structured-output-component-in-a-flow" class="table-of-contents__link toc-highlight">Use the Structured Output component in a flow</a></li><li><a href="#structured-output-parameters" class="table-of-contents__link toc-highlight">Structured Output parameters</a></li></ul></li><li><a href="#type-convert" class="table-of-contents__link toc-highlight">Type Convert</a><ul><li><a href="#use-the-type-convert-component-in-a-flow" class="table-of-contents__link toc-highlight">Use the Type Convert component in a flow</a></li><li><a href="#type-convert-parameters" class="table-of-contents__link toc-highlight">Type Convert parameters</a></li></ul></li><li><a href="#legacy-processing-components" class="table-of-contents__link toc-highlight">Legacy Processing components</a></li></ul></div></div></div></div></main></div></div></div><footer class="theme-layout-footer footer"><div class="container container-fluid"><div class="row footer__links"><div class="theme-layout-footer-column col footer__col"><div class="footer__title"></div><ul class="footer__items clean-list"><li class="footer__item"><div class="footer-links">
|
||
<span>© 2025 Langflow</span>
|
||
<span id="preferenceCenterContainer"> · <a href="https://langflow.org/preferences">Manage Privacy Choices</a></span>
|
||
</div></li></ul></div></div></div></footer><div style="position:fixed;right:21px;bottom:21px;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> |