Data Operations

Estimated reading: 4 minutes 137 views

The Data Operations component performs operations on Data objects, including extracting, filtering, and editing keys and values in the Data. For all options, see Available data operations. The output is a new Data object containing the modified data after running the selected operation.

Use the Data Operations component in a flow

The following example demonstrates how to use a Data Operations component in a flow using data from a webhook payload:

1. Create a flow with a Webhook component and a Data Operations component and then connect the Webhook component’s output to the Data Operations component’s Data input.

All operations in the Data Operations component require at least one Data input from another component. If the preceding component doesn’t produce Data output, you can use another component, such as the Type Convert component, to reformat the data before passing it to the Data Operations component. Alternatively, you could consider using a component that is designed to process the original data type, such as the Parser or DataFrame Operations components.

2. In the Operations field, select the operation you want to perform on the incoming Data. For this example, select the Select Keys operation.

3. Under Select Keys, add keys for name, username, and email. Click Add more to add a field for each key.

For this example, assume that the webhook will receive consistent payloads that always contain name, username, and email keys. The Select Keys operation extracts the value of these keys from each incoming payload.

4. Optional: If you want to view the output in the Playground, connect the Data Operations component’s output to a Chat Output component.

5. To test the flow, send the following request to your flow’s webhook endpoint. For more information about the webhook endpoint, see Trigger flows with webhooks.

curl -X POST “http://$ROBILITY FLOW_SERVER_URL/api/v1/webhook/$FLOW_ID” \

-H “Content-Type: application/json” \

-H “x-api-key: $ROBILITY FLOW_API_KEY” \

-d ‘{

  “id”: 1,

  “name”: “Leanne Graham”,

  “username”: “Bret”,

  “email”: “Sincere@april.biz”,

  “address”: {

    “street”: “Main Street”,

    “suite”: “Apt. 556”,

    “city”: “Springfield”,

    “zipcode”: “92998-3874”,

    “geo”: {

      “lat”: “-37.3159”,

      “lng”: “81.1496”

    }

  },

  “phone”: “1-770-736-8031 x56442”,

  “website”: “hildegard.org”,

  “company”: {

    “name”: “Acme-Corp”,

    “catchPhrase”: “Multi-layered client-server neural-net”,

    “bs”: “harness real-time e-markets”

  }

}’

6. To view the Data resulting from the Select Keys operation, do one of the following:

a. If you attached a Chat Output component, open the Playground to see the result as a chat message.

b. Click Inspect output on the Data Operations component.

Data Operations parameters

Many Data Operations component input parameters are conditional based on the selected Operation (operation).

Name Type Description
model HandleInput Input parameter. Connect the 'Language Model' output from a Language Model component. Required.
system_message MultilineInput Input parameter. A multi-line system instruction for all rows in the DataFrame.
df DataFrameInput Input parameter. The DataFrame whose column is treated as text messages, as specified by 'column_name'. Required.
column_name MessageTextInput Input parameter. The name of the DataFrame column to treat as text messages. If empty, all columns are formatted in TOML.
output_column_name MessageTextInput Input parameter. Name of the column where the model's response is stored. Default=model_response.
enable_metadata BoolInput Input parameter. If True, add metadata to the output DataFrame.
batch_results DataFrame Output parameter. A DataFrame with all original columns plus the model's response column.

Available data operations

Options for the operations input parameter are as follows. All operations act on an incoming Data object.

Name Required Inputs Process
Select Keys select_keys_input Selects specific keys from the data.
Literal Eval None Evaluates string values as Python literals.
Combine None Combines multiple data objects into one.
Filter Values filter_key, filter_values, operator Filters data based on key-value pair.
Append or Update append_update_data Adds or updates key-value pairs.
Remove Keys remove_keys_input Removes specified keys from the data.
Rename Keys rename_keys_input Renames keys in the data.
Share this Doc

Data Operations

Or copy link

CONTENTS