Skip to main content

Helpers

Helper components provide utility functions to help manage data, tasks, and other components in your flow.

Calculator

The Calculator component performs basic arithmetic operations on mathematical expressions. It supports addition, subtraction, multiplication, division, and exponentiation operations.

For an example of using this component in a flow, see the Python interpreter component.

Parameters
NameTypeDescription
expressionStringThe arithmetic expression to evaluate, such as 4*4*(33/22)+12-20.

Outputs

NameTypeDescription
resultDataThe calculation result as a Data object containing the evaluated expression.

Current date

The Current Date component returns the current date and time in a selected timezone. This component provides a flexible way to obtain timezone-specific date and time information within a Langflow pipeline.

Parameters

Inputs

NameTypeDescription
timezoneStringThe timezone for the current date and time.

Outputs

NameTypeDescription
current_dateStringThe resulting current date and time in the selected timezone.

Message history

info

Prior to Langflow 1.5, this component was two separate components called Chat History and Message Store.

This component provides combined chat history and message store functionality. This component can use Langflow's SQLite database or external memory to store and retrieve chat messages.

Chat memory is distinct from vector store memory, because it is built specifically for storing and retrieving chat messages from databases.

Memory components provide access to their respective external databases as memory. This allows Large Language Models (LLMs) or agents to access external memory for persistence and context retention.

In Retrieve mode, this component retrieves chat messages from Langflow tables or external memory. In Store mode, this component stores chat messages in Langflow tables or external memory.

In this example, one Message History component stores the complete chat history in a local Langflow table, which the other Message History component retrieves as context for the LLM to answer each question.

Message store and history components

To configure Langflow to store and retrieve messages from an external database instead of local Langflow memory, follow these steps.

  1. Add two Memory components to your flow. This example uses Redit Chat Memory.
  2. To enable external memory ports, in both Memory components, click Controls, and then enable External Memory.
  3. Connect the Memory ports to the Message History components. The flow looks like this: Message store and history components with external memory
  4. In the Redis Chat Memory components, add your connection information. These values are found in your Redis deployment. For more information, see the Redis documentation.

For more information on configuring memory in Langflow, see Memory.

Parameters

Inputs

NameTypeDescription
memoryMemoryRetrieve messages from an external memory. If empty, the Langflow tables are used.
senderStringFilter by sender type.
sender_nameStringFilter by sender name.
n_messagesIntegerThe number of messages to retrieve.
session_idStringThe session ID of the chat. If empty, the current session ID parameter is used.
orderStringThe order of the messages.
templateStringThe template to use for formatting the data. It can contain the keys {text}, {sender} or any other key in the message data.

Outputs

NameTypeDescription
messagesDataThe retrieved messages as Data objects.
messages_textMessageThe retrieved messages formatted as text.
dataframeDataFrameA DataFrame containing the message data.

Legacy components

Legacy components are available for use but are no longer supported.

Create List

This component dynamically creates a record with a specified number of fields.

Parameters

Inputs

NameTypeDescription
n_fieldsIntegerThe number of fields to be added to the record.
text_keyStringThe key used as text.

Outputs

NameTypeDescription
listListThe dynamically created list with the specified number of fields.

ID Generator

This component generates a unique ID.

Parameters

Inputs

NameTypeDescription
unique_idStringThe generated unique ID.

Outputs

NameTypeDescription
idStringThe generated unique ID.

Output Parser

This component transforms the output of a language model into a specified format. It supports CSV format parsing, which converts LLM responses into comma-separated lists using Langchain's CommaSeparatedListOutputParser.

note

This component only provides formatting instructions and parsing functionality. It does not include a prompt. You'll need to connect it to a separate Prompt component to create the actual prompt template for the LLM to use.

Both the Output Parser and Structured Output components format LLM responses, but they have different use cases. The Output Parser is simpler and focused on converting responses into comma-separated lists. Use this when you just need a list of items, for example ["item1", "item2", "item3"]. The Structured Output is more complex and flexible, and allows you to define custom schemas with multiple fields of different types. Use this when you need to extract structured data with specific fields and types.

To use this component:

  1. Create a Prompt component and connect the Output Parser's format_instructions output to it. This ensures the LLM knows how to format its response.
  2. Write your actual prompt text in the Prompt component, including the {format_instructions} variable. For example, in your Prompt component, the template might look like:

_10
{format_instructions}
_10
Please list three fruits.

  1. Connect the output_parser output to your LLM model.

  2. The output parser converts this into a Python list: ["apple", "banana", "orange"].

Parameters

Inputs

NameTypeDescription
parser_typeStringThe parser type. Currently supports "CSV".

Outputs

NameTypeDescription
format_instructionsStringPass to a prompt template to include formatting instructions for LLM responses.
output_parserParserThe constructed output parser that can be used to parse LLM responses.
Search