mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 15:19:46 +08:00
* docs: migrate code blocks from CodeSnippet to native Prism Replace the custom CodeSnippet component (@code-hike/lighter) with Docusaurus's native @theme/CodeBlock across all MDX files (current and versioned docs). Add bash to additionalLanguages and swizzle prism-include-languages.js to add custom token highlighting for shell commands and flags. Remove @code-hike/mdx dependency. * docs: improve inline code styling Darken inline code background, increase horizontal padding to 0.4em, fix vertical alignment, and remove border in light mode. * docs: address PR review — fix code slice regression and CSS/regex polish - Inline RecursiveCharacterTextSplitter inputs and methods as literal code blocks in concepts-components.mdx (current + 1.8.0 + 1.9.0), restoring the focused slices lost when migrating from CodeSnippet - Scope bash-plain Prism regex to unambiguous CLI subcommands only, removing generic bash builtins (run, add, get, set, start, stop, etc.) - Merge duplicate .theme-code-block CSS rules into a single declaration * fix(docs): prevent horizontal scroll on API docs pages The Redoc two-column layout (sidebar 300px + api-content 1300px) totals 1600px, expanding .main-wrapper beyond narrower viewports because it has overflow:visible. Clips at .main-wrapper using the html.plugin-redoc class that Docusaurus adds on API pages only. * fix(docs): API docs sidebar and layout fixes - Disable Redoc built-in search (disableSearch: true) - Pin sidebar top to navbar height (top: 60px) so it never hides behind navbar - Remove hardcoded #111 background from dark mode sidebar * fix(docs): render markdown correctly in API docs descriptions The _clean_descriptions function was converting newlines to <br> tags, mixing HTML with Markdown. CommonMark stops parsing Markdown headings (###) inside HTML blocks, causing them to appear as literal text in Redoc. Replace the <br> conversion with a simple strip() so descriptions remain pure Markdown and Redoc renders headings, lists, and code blocks correctly. * feat(docs): align API docs colors with Langflow brand - Set primaryColor to #F471B5 (Langflow pink) - Add HTTP method badge colors matching Langflow palette - Set schema.linesColor and requireLabelColor to brand pink - Set inline code color to pink, headers to #e3e3e3 - Set sidebar background to #18181b (matches frontend dark bg) - Set rightPanel background to #0d0d0f, codeBlock to #161618 - Refactor: move color config from CSS to theme.theme where safe - Remove dead search input CSS (search disabled via disableSearch:true) - Consolidate duplicate .menu-content rules * wip(docs): API docs styling — colors, components, light/dark themes * fix(docs): fix Response samples h3 title padding and refactor HTTP method button CSS * feat(docs): add sidebar dark background, active item styles, and right panel color adjustments * fix(docs): add sidebar borders and remove operation divider border * fix(docs): fix expanded response background and align dark/light theme colors * refactor(docs): standardize selectors, comments and remove duplicate rules in redocusaurus.css * refactor(docs): apply PR review — CSS custom properties, version pin, dom version comments, fix overflow * fix(docs): fix Redocly badge visibility covered by sidebar background * fix(docs): extend sidebar border-right to Redocly badge area * refactor(docs): replace hardcoded #ffffff label color with --redoc-text-label variable * fix(docs): lighten inline code background in API docs dark theme Redoc's default typography.code.backgroundColor (rgba(38, 50, 56, 0.05)) is nearly invisible over the dark background. Override it with rgba(255, 255, 255, 0.05) in dark theme only, excluding pre > code so code sample blocks stay unaffected. * feat(docs): align docs primary pink with API spec brand color Use #f471b5 (API spec primaryColor) as --ifm-color-primary in dark theme and #e44fa0 (slightly darkened for contrast on white) in light theme. Remove dark-theme pink overrides in sidebar.css (#ff6ad0 CTA and hsla(329, 55%, 68%) active TOC link) — they compensated for the old muted pink and are redundant now that the primary itself is bright. * feat(docs): lighten dark theme text colors for better readability Bump body text (#a8a8b0 -> #bcbcc4), headings (#cdcdd4 -> #dcdce2) and sidebar menu (#8a8a92 -> #9c9ca4) one step brighter. * chore(docs): add IBM Equal Access accessibility-checker setup Add accessibility-checker as devDependency with aceconfig.js (policy IBM_Accessibility, JSON reports in docs/a11y-results/, gitignored). Scan with: npx achecker <url> against a built docs site. * fix(docs): WCAG AA contrast and ARIA fixes across docs and API reference Validated with IBM Equal Access scans (light theme): home, quickstart and component pages at 0 violations; /api from 3382 down to 167 (all remaining are Redoc-internal DOM: schema table headers, svg/select labels). Docs site: - Light primary pink #d11074 — passes 4.5:1 on white and inline-code bg - Light Prism palette darkened per-token to pass 4.5:1 on #f9f9fd - TabItem swizzled to give tabpanels an accessible name (aria-label) - codeBlockA11y client module: scrollable code blocks get role=region + unique label; non-scrollable ones lose the needless tabindex API reference (Redocusaurus): - redocA11y client module: role=main on api-content, role=navigation on sidebar — fixes 1924 aria_content_in_landmark violations - HTTP method badges and response chips darkened to pass with white text - Light-theme overrides: accessible pink #cd1072 for links, required markers, constraint chips, schema tree lines; darker grays for utility buttons and type labels (incl. 0.7-opacity wrapper fix) - Sidebar active/hover items use regular text color, method badges keep their own colors; expandable property names match non-expandable ones * fix(docs): WCAG AA contrast fixes for dark theme Validated with IBM Equal Access scans in dark mode (temporary colorMode.defaultMode flip during scanning): home, quickstart and component pages at 0 violations; /api matches light at 167 remaining (all Redoc-internal DOM: table headers, svg/select labels). - Code block comments/line numbers #4a5060 -> #798197 (4.56:1 on #18181a) - Redoc dark sample tokens: boolean/null #e95c59, number #5392b8 - Status-code tabs: lift docusaurus-theme-redoc's #303846 !important selected-tab rule with a higher-specificity override - oneOf variant buttons: dark text in both themes (their white/pink backgrounds are theme-independent) - redocA11y client module: patch response chip colors (success green / error red) to dark-accessible variants when data-theme=dark — a single Redoc theme color cannot pass on both light and dark derived backgrounds, and status is only distinguishable by computed color * fix(docs): resolve remaining Redoc-internal accessibility violations Extend the redocA11y client module with semantic patches for Redoc DOM the theme cannot reach (validated: 0 IBM Equal Access violations on all scanned pages in both light and dark themes): - Decorative svg chevrons/arrows: aria-hidden=true (svg_graphics_labelled) - Content-type dropdowns: aria-label (input_label_exists) - Schema field tables (2-col name|description layout, no <th> anywhere): role=presentation — content reads in DOM order; role=rowheader on <td> is invalid ARIA inside a native table (table_headers_exists/related) - Semantic patches run on the next animation frame after DOM changes so Redoc's lazy-rendered operations are covered immediately; the heavier color patch stays debounced * ci(docs): gate docs accessibility with IBM Equal Access scans Add test-docs-accessibility job to docs_test.yml (rides the existing docs/** path filter from ci.yml): build + scan 4 representative pages (home, quickstart, component page, /api) in light theme, then flip colorMode.defaultMode to dark, rebuild and scan again. - scripts/a11y-ci.sh: serves the build and runs npx achecker per page with one retry to absorb Redoc lazy-render timing flakes; any real violation fails the job (failLevels: violation) - aceconfig.js: pin ruleArchive to 19May2026 so IBM rule updates don't break CI without a deliberate bump * ci(docs): fix Chrome sandbox launch on Ubuntu 24.04 runners Ubuntu 24.04 restricts unprivileged user namespaces via AppArmor, which prevents puppeteer's Chrome (used by the IBM checker) from starting its sandbox. Re-enable them with the documented sysctl workaround instead of weakening the browser with --no-sandbox. * fix(docs): align response status code with description text Redoc sets vertical-align: top and a smaller line-height on the status code <strong> inside response buttons, leaving "200" visually higher than "Successful Response". Align both to the shared text baseline. * refactor(docs): apply PR review feedback - redocA11y: match only real Redoc routes (/api, /api/workflow) — a bare startsWith("/api") also matched docs pages like /api-request and leaked one body MutationObserver per navigation - codeBlockA11y: also observe the hidden attribute — Docusaurus tabs toggle panels via hidden (no childList mutation), so scrollable blocks inside an initially hidden tab were never re-evaluated for tabindex - Extract Prism themes to src/prismThemes.js (docusaurus.config.js was past the 600-line red flag) - concepts-components.mdx (current + 1.9.0 + 1.8.0): comment pointing hardcoded snippets to recursive_character.py to mitigate drift Validated: clean build + IBM Equal Access scans 4/4 passing. * replace-openapi-file-with-1.10 * migrate-prism-changes-to-1.10-version * a11y-script-dont-block --------- Co-authored-by: Mendon Kissling <59585235+mendonk@users.noreply.github.com>
273 lines
16 KiB
Plaintext
273 lines
16 KiB
Plaintext
---
|
|
title: Components overview
|
|
slug: /concepts-components
|
|
---
|
|
|
|
import Icon from "@site/src/components/icon";
|
|
|
|
Components are the building blocks of your flows.
|
|
Like classes in an application, each component is designed for a specific use case or integration.
|
|
|
|
:::tip
|
|
Langflow provides keyboard shortcuts for the workspace.
|
|
|
|
In the Langflow header, click your profile icon, select **Settings**, and then click **Shortcuts** to view the available shortcuts.
|
|
:::
|
|
|
|
## Add a component to a flow {#component-menus}
|
|
|
|
To add a component to a flow, drag the component from the <Icon name="Component" aria-hidden="true" /> **Core components** or <Icon name="Blocks" aria-hidden="true" /> **Bundles** menu into the [workspace](/concepts-overview#workspace).
|
|
|
|
Components are grouped by type or provider, and some components are hidden by default:
|
|
|
|
* <Icon name="Component" aria-hidden="true" /> **Core components**: Langflow's base components are grouped by purpose, such as **Inputs and Outputs** or **Data**.
|
|
These components either provide generic functionality, like loops and parsing, or they provide single components that support multiple third-party integrations.
|
|
|
|
* <Icon name="Blocks" aria-hidden="true" /> **Bundles**: Bundles contain one or more components that support specific third-party integrations, and they are grouped by service provider.
|
|
|
|
* **Legacy**: These components are hidden by default.
|
|
For more information, see [Legacy components](#legacy-components).
|
|
|
|
### Configure a component
|
|
|
|
After adding a component to a flow, configure the component's parameters and connect it to the other components in your flows.
|
|
|
|
Each component has inputs, outputs, parameters, and controls related to the component's purpose.
|
|
By default, components show only required and common options.
|
|
To access additional settings and controls, including meta settings, use the [component inspection panel](#component-inspection-panel).
|
|
|
|
### Component inspection panel {#component-inspection-panel}
|
|
|
|
When you select a component in the workspace, a component inspection panel appears on the right side of the screen.
|
|
|
|
The inspection panel displays all of a component's parameters, including hidden or advanced parameters.
|
|
|
|
### Component header menus
|
|
|
|
To access a component's header menu, click the component in your workspace.
|
|
|
|

|
|
|
|
The following options are available directly on the header menu:
|
|
|
|
- **Code**: Modify component settings by directly editing the component's Python code.
|
|
- **Freeze**: Freeze a component and all upstream components to prevent re-running. For more information, see [Freeze a component](#freeze-a-component).
|
|
- **Tool Mode**: Enable this option when combining a component with an **Agent** component.
|
|
|
|
For all other options, including **Delete** and **Duplicate** controls, click <Icon name="Ellipsis" aria-hidden="true" /> **Show More**.
|
|
|
|
### Rename a component
|
|
|
|
To modify a component's name or description, click the component in the workspace, and then click <Icon name="PencilLine" aria-hidden="true"/> **Edit**.
|
|
Component descriptions accept Markdown syntax.
|
|
|
|
### Run a component
|
|
|
|
To run a single component, click <Icon name="Play" aria-label="Play button" /> **Run component**.
|
|
A **Last Run** value indicates that the component ran successfully.
|
|
|
|
Running a single component is different from running an entire flow. In a single component run, the `build_vertex` function is called, which builds and runs only the single component with direct inputs provided through the visual editor (the `inputs_dict` parameter). The `VertexBuildResult` data is passed to the `build_and_run` method that calls the component's `build` method and runs it. Unlike running an entire flow, running a single component doesn't automatically execute its upstream dependencies.
|
|
|
|
### Inspect component output and logs
|
|
|
|
To view the output and logs for a single component, click <Icon name="TextSearch" aria-hidden="true" /> **Inspect**.
|
|
|
|
### Freeze a component
|
|
|
|
:::info
|
|
Freezing a component also freezes all components upstream of the selected component.
|
|
:::
|
|
|
|
Use the freeze option if you expect consistent output from a component _and all upstream components_, and you only need to run those components once.
|
|
|
|
Freezing a component prevents that component and all upstream components from re-running, and it preserves the last output state for those components.
|
|
Any future flow runs use the preserved output.
|
|
|
|
To freeze a component, click the component in the workspace to expose the component's header menu, and then click **Freeze**.
|
|
|
|
## Component ports
|
|
|
|
Around the border of each component, there are circular port icons like <Icon name="Circle" size="16" aria-label="Indigo message port" style={{ color: '#4f46e5', fill: '#4f46e5' }}/>.
|
|
These indicate a component _connection point_ or _port_.
|
|
|
|
Ports either accept input or produce output of a specific data type.
|
|
You can infer the data type from the field the port is attached to or from the [port's color](#port-colors).
|
|
For example, the **System Message** field accepts [message data](/data-types#message), as illustrated by the blue port icon: <Icon name="Circle" size="16" aria-label="Indigo message port" style={{ color: '#4f46e5', fill: '#4f46e5' }} />.
|
|
|
|

|
|
|
|
When building flows, connect output ports to input ports of the same type (color) to transfer that type of data between two components.
|
|
For information about the programmatic representation of each data type, see [Langflow data types](/data-types).
|
|
|
|
:::tip
|
|
* In the workspace, hover over a port to see connection details for that port.
|
|
Click a port to <Icon name="Search" aria-hidden="true" /> **Search** for compatible components.
|
|
|
|
* If two components have incompatible data types, you can use a processing component like the [**Type Convert** component](/type-convert) to convert the data between components.
|
|
:::
|
|
|
|
### Dynamic ports
|
|
|
|
Some components have ports that are dynamically added or removed.
|
|
For example, the **Prompt Template** component accepts [inputs wrapped in curly braces](/components-prompts#define-variables-in-prompts), and new ports are opened when a value wrapped in curly braces is detected in the **Template** field.
|
|
|
|

|
|
|
|
### Output type selection
|
|
|
|
All components produce output that is either sent to another component in the flow or returned as the final flow result.
|
|
|
|
Some components can produce multiple types of output:
|
|
|
|
* If the component emits all types at once, the component has multiple output ports in the visual editor. In component code, this is represented by `group_outputs=True`
|
|
|
|
* If the component emits only one type, you must select the output type by clicking the output label near the output port, and then selecting the desired output type. In component code, this is represented by `group_outputs=False` or omitting the `group_outputs` parameter.
|
|
|
|
For example, a language model component can output _either_ a **Model Response** or **Language Model**.
|
|
The **Model Response** output produces [`Message`](/data-types#message) data that can be passed to another component's `Message` port.
|
|
The **Language Model** output must be connected to a component with a **Language Model** input, such as the [**Structured Output** component](/structured-output), that uses the attached LLM to power the receiving component's reasoning.
|
|
|
|

|
|
|
|
### Port colors
|
|
|
|
Component port colors indicate the data type ingested or emitted by the port.
|
|
For example, a **Message** port either accepts or emits `Message` data.
|
|
|
|
The following table lists the component data types and their corresponding port colors:
|
|
|
|
| Data type | Port color | Port icon example |
|
|
|-----------|--------------|----------|
|
|
| JSON | Red | <Icon name="Circle" size="16" aria-label="Red data port" style={{ color: '#dc2626', fill: '#dc2626' }} /> |
|
|
| Table | Pink | <Icon name="Circle" size="16" aria-label="Pink dataframe port" style={{ color: '#ec4899', fill:'#ec4899' }} /> |
|
|
| Embeddings | Emerald | <Icon name="Circle" size="16" aria-label="Emerald embeddings port" style={{ color: '#10b981', fill: '#10b981' }} /> |
|
|
| LanguageModel | Fuchsia | <Icon name="Circle" size="16" aria-label="Fuchsia language model port" style={{ color: '#c026d3', fill: '#c026d3' }} /> |
|
|
| Memory | Orange | <Icon name="Circle" size="16" aria-label="Orange memory port" style={{ color: '#f97316', fill: '#f97316' }} /> |
|
|
| Message | Indigo | <Icon name="Circle" size="16" aria-label="Indigo message port" style={{ color: '#4f46e5', fill: '#4f46e5' }} /> |
|
|
| Tool | Cyan | <Icon name="Circle" size="16" aria-label="Cyan tool port" style={{ color: '#06b6d4', fill: '#06b6d4' }} /> |
|
|
| Unknown or multiple types | Gray | <Icon name="Circle" size="16" aria-label="Gray unknown port" style={{ color: '#9CA3AF', fill: '#9CA3AF' }} /> |
|
|
|
|
## Component code
|
|
|
|
You can edit components in the [workspace](/concepts-overview#workspace) and in code. When editing a flow, select a component, and then click <Icon name="Code" aria-hidden="true"/> **Code** to see and edit the component's underlying Python code.
|
|
|
|
All components have underlying code that determines how you configure them and what actions they can perform.
|
|
In the context of creating and running flows, component code does the following:
|
|
|
|
* Determines what configuration options to show in the visual editor.
|
|
* Validates inputs based on the component's defined input types.
|
|
* Processes data using the configured parameters, methods, and functions.
|
|
* Passes results to the next component in the flow.
|
|
|
|
All components inherit from a base `Component` class that defines the component's interface and behavior.
|
|
For example, the [**Recursive Character Text Splitter** component](https://github.com/langflow-ai/langflow/blob/main/src/lfx/src/lfx/components/langchain_utilities/recursive_character.py) is a child of the [`LCTextSplitterComponent`](https://github.com/langflow-ai/langflow/blob/main/src/lfx/src/lfx/base/textsplitters/model.py) class.
|
|
|
|
Each component's code includes definitions for inputs and outputs, which are represented in the workspace as [component ports](#component-ports).
|
|
For example, the `RecursiveCharacterTextSplitter` has four inputs. Each input definition specifies the input type, such as `IntInput`, as well as the encoded name, display name, description, and other parameters for that specific input.
|
|
These values determine the component settings, such as display names and tooltips in the visual editor.
|
|
|
|
{/* Snippet copied from src/lfx/src/lfx/components/langchain_utilities/recursive_character.py — keep in sync if the component changes. */}
|
|
```python title="RecursiveCharacterTextSplitter inputs (from recursive_character.py)" showLineNumbers
|
|
inputs = [
|
|
IntInput(
|
|
name="chunk_size",
|
|
display_name="Chunk Size",
|
|
info="The maximum length of each chunk.",
|
|
value=1000,
|
|
),
|
|
IntInput(
|
|
name="chunk_overlap",
|
|
display_name="Chunk Overlap",
|
|
info="The amount of overlap between chunks.",
|
|
value=200,
|
|
),
|
|
DataInput(
|
|
name="data_input",
|
|
display_name="Input",
|
|
info="The texts to split.",
|
|
input_types=["Document", "Data", "JSON"],
|
|
required=True,
|
|
),
|
|
MessageTextInput(
|
|
name="separators",
|
|
display_name="Separators",
|
|
info='The characters to split on.\nIf left empty defaults to ["\\n\\n", "\\n", " ", ""].',
|
|
is_list=True,
|
|
),
|
|
]
|
|
```
|
|
|
|
Additionally, components have methods or functions that handle their functionality.
|
|
For example, the `RecursiveCharacterTextSplitter` has two methods:
|
|
|
|
{/* Snippet copied from src/lfx/src/lfx/components/langchain_utilities/recursive_character.py — keep in sync if the component changes. */}
|
|
```python title="RecursiveCharacterTextSplitter methods (from recursive_character.py)" showLineNumbers
|
|
def get_data_input(self) -> Any:
|
|
return self.data_input
|
|
|
|
def build_text_splitter(self) -> TextSplitter:
|
|
if not self.separators:
|
|
separators: list[str] | None = None
|
|
else:
|
|
# check if the separators list has escaped characters
|
|
# if there are escaped characters, unescape them
|
|
separators = [unescape_string(x) for x in self.separators]
|
|
|
|
return RecursiveCharacterTextSplitter(
|
|
separators=separators,
|
|
chunk_size=self.chunk_size,
|
|
chunk_overlap=self.chunk_overlap,
|
|
)
|
|
```
|
|
|
|
The `get_data_input` method retrieves the text to be split from the component's input, which makes the data available to the class.
|
|
The `build_text_splitter` method creates a `RecursiveCharacterTextSplitter` object by calling its parent class's `build` method. Then, the text is split with the created splitter and passed to the next component.
|
|
|
|
## Component versions
|
|
|
|
Component versions and states are stored in an internal Langflow database. When you add a component to a flow, you create a detached copy of the component based on the information in the Langflow database.
|
|
These copies are detached from the primary Langflow database, and they don't synchronize with any updates that can occur when you upgrade your Langflow version.
|
|
|
|
In other words, an individual instance of a component retains the version number and state from the moment you add it to a specific flow. For example, if a component is at version 1.0 when you add it to a flow, it remains at version 1.0 _in that flow_ unless you update it.
|
|
|
|
### Update component versions
|
|
|
|
When editing a flow in the workspace, Langflow notifies you if a component's workspace version is behind the database version so you can update the component's workspace version:
|
|
|
|
* **Update ready**: This notification means the component update contains no breaking changes.
|
|
* **Update available**: This notification means the component update might contain breaking changes.
|
|
|
|
Breaking changes modify component inputs and outputs, causing the components to be disconnected and break the flow. After updating the component, you might need to edit the component settings or reconnect component ports.
|
|
|
|
There are two ways to update components:
|
|
|
|
* Click **Update** to update a single component. This is recommended for updates without breaking changes.
|
|
* Click **Review** to view all available updates and create a snapshot before updating. This is recommended for updates with breaking changes.
|
|
|
|
To save a snapshot of your flow before updating the components, enable **Create backup flow before updating**. Backup flows are stored in the same project folder as the original flow with the suffix `(backup)`.
|
|
|
|
To update specific components, select the components you want to update, and then click **Update Components**.
|
|
|
|
Components are updated to the latest available version, based on the version of Langflow you are running.
|
|
|
|
## Group components
|
|
|
|
Multiple components can be grouped into a single component for reuse. This is useful for organizing large flows by combining related components together, such as a RAG **Agent** component and it's associated tools or vector store components.
|
|
|
|
1. Hold <kbd>Shift</kbd>, and then click and drag to highlight all components you want to merge. Components must be completely within the selection area to be merged.
|
|
|
|
Alternatively, to select components for merging one by one, hold <kbd>Ctrl</kbd> on Windows or <kbd>Cmd</kbd> on Mac, and then click each component to add them to the group.
|
|
|
|
2. Release the mouse and keyboard, and then click **Group** to merge the components into a single, group component.
|
|
|
|
Grouped components are configured and managed as a single component, including the component name, code, and settings.
|
|
|
|
To ungroup the components, click the component in the workspace to expose the component's header menu, click <Icon name="Ellipsis" aria-hidden="true" /> **Show More**, and then select **Ungroup**.
|
|
|
|
If you want to reuse this grouping in other flows, click the component in the workspace to expose the component's header menu, click <Icon name="Ellipsis" aria-hidden="true" /> **Show More**, and then select **Save** to save the component to the <Icon name="Component" aria-hidden="true" /> **Core components** menu as a custom component.
|
|
|
|
## Legacy components
|
|
|
|
import PartialLegacy from '@site/docs/_partial-legacy.mdx';
|
|
|
|
<PartialLegacy /> |