Langflow 1.13 just released!
gradient
  1. Home  /

  2. Blog  /

  3. Langflow Micro Tutorials — Enhanced Truncator

Langflow Micro Tutorials — Enhanced Truncator

Rodrigo Nader

Written by Rodrigo Nader

September 15, 2023

Welcome back to our Langflow micro tutorials series! We’re continuing with simple Langflow examples, emphasizing the design of custom components.

This article includes a link for downloading the described flow. Use it to modify and understand the components involved.

Today, we’re focusing on an enhanced version of our Document Truncator, demonstrating how to add options to a custom component. Enjoy!

Main Features

Enhanced Document Truncator: This custom component enables document truncation while preserving either the initial or final characters as determined by the truncate_size. The build_config method is used to customize the input fields, including the dropdown selection box.

Objective

The aim of this flow is to demonstrate the usefulness of field customization when creating custom components.

In this updated version of our custom component, we not only let the user decide how many chars to truncate but also add a dropdown field to decide how this process will happen — pass either the first or last truncate_size characters to the prompt template — which can be done by using the build_config method.

Here we created a str input field and assigned it to have options (meaning it is a dropdown selector) in the config dict. We also defined this field as required and created an info tooltip for it.

Below is the corresponding build_config function:

def build_config(self): 
    return {"how": { "options": ["first", "last"],  
            "required": True,  
            "info": "Select whether to retain the first or last characters as specified by the 'truncate_size'." }}

Finally, we also set the self.repr_value variable, which determines the content to be displayed in the component status icon. Here I chose to display the truncated text.

This status will show completely different outputs depending on the how field input_._


Download Flow (gist)


Similar Posts

Langflow 1.13 Desktop is now available

Langflow 1.13 Desktop is now available

Langflow Dev Team

Written by Langflow Dev Team

November 2, 2026

Langflow 1.13 Desktop is now available. For the full list of new features, see the OSS release announcement.

Langflow 1.13 released: Audit logs, connections, and concurrent editing

Langflow 1.13 released: Audit logs, connections, and concurrent editing

Langflow Dev Team

Written by Langflow Dev Team

October 22, 2026

Langflow 1.13 adds audit logging, reusable OAuth connections, and concurrent editing checks that keep one save from replacing another.

Langflow 1.12 Desktop is now available

Langflow 1.12 Desktop is now available

Langflow Dev Team

Written by Langflow Dev Team

September 16, 2026

Langflow 1.12 Desktop is now available. For the full list of new features, see the OSS release announcement.

Build the next version of Langflow with us

Build the next version of Langflow with us

Langflow Dev Team

Written by Langflow Dev Team

September 3, 2026

We are taking 25 people into early access.