Welcome back to our Langflow micro tutorials series! In this article, we’ll continue exploring simple Langflow examples and the design of custom components.
You can download the flow mentioned in this article to modify and understand the components used.
Today, we’ll focus on reproducing a Langchain Transform Chain in Langflow. Hope you enjoy it!
Main Features
Transform Chain: A custom component with a special method called
perform_action
Objective
In Langchain, a Transform Chain is designed to modify input data before sending it to another chain. It uses input and output variables that are transformed by a function (hereby called
perform_actionThis function takes a dictionary of input variables and returns a dictionary of output variables, allowing for arbitrary Python code to change the inputs. Transform Chains are useful for tasks like segmenting long text, translating language, or extracting metadata. More information is available here.
The goal is to bring this Transform Chain feature into Langflow, converting any Python function into a chain type. This allows us to utilize all the chain-related functionalities Langflow offers. For example, they can be used as input to the CombineDocs Chain or Sequential Chains and can work with prompt templates or even open up the chat interface.
To use it, just open the code of the custom component and play around with the
perform_action
In this case, we're simplifying it and passing a single input variable to the
perform_actionbuildselfbuildperform_actionfooOnce the chat interface is activated, just interact with your function as if it’s a chain.

Notice that this opens up possibilities for including diverse fields in the component. For example,
foo









