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:
parent
c68372bb73
commit
fa76d568cd
2 changed files with 41 additions and 9 deletions
|
|
@ -3,6 +3,8 @@ title: Helpers
|
||||||
slug: /components-helpers
|
slug: /components-helpers
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Icon from "@site/src/components/icon";
|
||||||
|
|
||||||
# Helper components in Langflow
|
# Helper components in Langflow
|
||||||
|
|
||||||
Helper components provide utility functions to help manage data, tasks, and other components in your flow.
|
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](
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 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:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
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
|
### Inputs
|
||||||
|
|
||||||
| Name | Display Name | Type | Info | Required |
|
| Name | Display Name | Type | Info |
|
||||||
|------|--------------|------|------|----------|
|
|------|--------------|------|------|
|
||||||
| model | Language Model | HandleInput | Connect the 'Language Model' output from your LLM component here. | Yes |
|
| 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. | No |
|
| system_message | System Message | MultilineInput | Multi-line system instruction for all rows in the DataFrame. |
|
||||||
| df | DataFrame | DataFrameInput | The DataFrame whose column (specified by 'column_name') will be treated as text messages. | Yes |
|
| df | DataFrame | DataFrameInput | The DataFrame whose column is treated as text messages, as specified by 'column_name'. Required. |
|
||||||
| column_name | Column Name | StrInput | The name of the DataFrame column to treat as text messages. Default='text'. | Yes |
|
| 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
|
### Outputs
|
||||||
|
|
||||||
| Name | Display Name | Method | Info |
|
| 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
|
## Create List
|
||||||
|
|
||||||
|
|
|
||||||
BIN
docs/static/img/component-batch-run.png
vendored
Normal file
BIN
docs/static/img/component-batch-run.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 312 KiB |
Loading…
Add table
Add a link
Reference in a new issue