docs: batch run component example (#7542)

* init

* add-instructions-and-image-for-batch-run

* Apply suggestions from code review

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>

* update-table-values

---------

Co-authored-by: KimberlyFields <46325568+KimberlyFields@users.noreply.github.com>
This commit is contained in:
Mendon Kissling 2025-04-11 09:19:31 -04:00 committed by GitHub
commit fa76d568cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 9 deletions

View file

@ -3,6 +3,8 @@ title: Helpers
slug: /components-helpers
---
import Icon from "@site/src/components/icon";
# Helper components in Langflow
Helper components provide utility functions to help manage data, tasks, and other components in your flow.
@ -17,24 +19,54 @@ This example flow stores and retrieves chat history from an [AstraDBChatMemory](
![Sample Flow storing Chat Memory in AstraDB](/img/astra_db_chat_memory_rounded.png)
## Batch Run Component
## Batch Run
The Batch Run component runs a language model over each row of a [DataFrame](/concepts-objects#dataframe-object) text column and returns a new DataFrame with the original text and the model's response.
The **Batch Run** component runs a language model over **each row** of a [DataFrame](/concepts-objects#dataframe-object) text column and returns a new DataFrame with the original text and an LLM response.
The response contains the following columns:
* `text_input`: The original text from the input DataFrame.
* `model_response`: The model's response for each input.
* `batch_index`: The processing order, with a `0`-based index.
* `metadata` (optional): Additional information about the processing.
These columns, when connected to a **Parser** component, can be used as variables within curly braces.
To use the Batch Run component with a **Parser** component, do the following:
1. Connect a **Model** component to the **Batch Run** component's **Language model** port.
2. Connect a component that outputs DataFrame, like **File** component, to the **Batch Run** component's **DataFrame** input.
3. Connect the **Batch Run** component's **Batch Results** output to a **Parser** component's **DataFrame** input.
The flow looks like this:
![A batch run component connected to OpenAI and a Parser](/img/component-batch-run.png)
4. In the **Column Name** field of the **Batch Run** component, enter a column name based on the data you're loading from the **File** loader. For example, to process a column of `name`, enter `name`.
5. Optionally, in the **System Message** field of the **Batch Run** component, enter a **System Message** to instruct the connected LLM on how to process your file. For example, `Create a business card for each name.`
6. In the **Template** field of the **Parser** component, enter a template for using the **Batch Run** component's new DataFrame columns.
To use all three columns from the **Batch Run** component, include them like this:
```text
record_number: {batch_index}, name: {text_input}, summary: {model_response}
```
7. To run the flow, in the **Parser** component, click <Icon name="Play" aria-label="Play icon" />.
8. To view your created DataFrame, in the **Parser** component, click <Icon name="TextSearch" aria-label="Inspect icon" />.
9. Optionally, connect a **Chat Output** component, and open the **Playground** to see the output.
### Inputs
| Name | Display Name | Type | Info | Required |
|------|--------------|------|------|----------|
| model | Language Model | HandleInput | Connect the 'Language Model' output from your LLM component here. | Yes |
| system_message | System Message | MultilineInput | Multi-line system instruction for all rows in the DataFrame. | No |
| df | DataFrame | DataFrameInput | The DataFrame whose column (specified by 'column_name') will be treated as text messages. | Yes |
| column_name | Column Name | StrInput | The name of the DataFrame column to treat as text messages. Default='text'. | Yes |
| Name | Display Name | Type | Info |
|------|--------------|------|------|
| model | Language Model | HandleInput | Connect the 'Language Model' output from your LLM component here. Required. |
| system_message | System Message | MultilineInput | Multi-line system instruction for all rows in the DataFrame. |
| df | DataFrame | DataFrameInput | The DataFrame whose column is treated as text messages, as specified by 'column_name'. Required. |
| column_name | Column Name | MessageTextInput | The name of the DataFrame column to treat as text messages. Default='text'. Required. |
| enable_metadata | Enable Metadata | BoolInput | If True, add metadata to the output DataFrame. |
### Outputs
| Name | Display Name | Method | Info |
|------|--------------|--------|------|
| batch_results | Batch Results | run_batch | A DataFrame with two columns: 'text_input' and 'model_response'. |
| batch_results | Batch Results | run_batch | A DataFrame with columns: 'text_input', 'model_response', 'batch_index', and optional 'metadata' containing processing information. |
## Create List

BIN
docs/static/img/component-batch-run.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 KiB