diff --git a/docs/docs/Components/components-agents.mdx b/docs/docs/Components/components-agents.mdx index b6c96e010..47e4bc81b 100644 --- a/docs/docs/Components/components-agents.mdx +++ b/docs/docs/Components/components-agents.mdx @@ -43,7 +43,7 @@ For examples of flows using the **Agent** and **MCP Tools** components, see the The **Agent** component is the primary agent actor in your agent flows. This component uses an LLM integration to respond to input, such as a chat message or file upload. -The agent can use the tools already available in the base LLM model as well as additional tools that you connect to the **Agent** component's **Tools** port. +The agent can use the tools already available in the base LLM as well as additional tools that you connect to the **Agent** component's **Tools** port. You can connect any Langflow component as a tool, including other **Agent** components and MCP servers through the [**MCP Tools** component](#mcp-connection). For more information about using this component, see [Use Langflow agents](/agents). diff --git a/docs/docs/Components/components-data.mdx b/docs/docs/Components/components-data.mdx index 3bc8b7a16..82e272275 100644 --- a/docs/docs/Components/components-data.mdx +++ b/docs/docs/Components/components-data.mdx @@ -396,7 +396,7 @@ There are two settings that control the output of the **URL** component at diffe When used as a standard component in a flow, the **URL** component must be connected to a component that accepts the selected output data type (`DataFrame` or `Message`). You can connect the **URL** component directly to a compatible component, or you can use a [**Type Convert** component](/components-processing#type-convert) to convert the output to another type before passing the data to other components if the data types aren't directly compatible. -Processing components, like the **Type Convert** component, are useful with the **URL** component because it can extract a large amount of data from the crawled pages. +**Processing** components like the **Type Convert** component are useful with the **URL** component because it can extract a large amount of data from the crawled pages. For example, if you only want to pass specific fields to other components, you can use a [**Parser** component](/components-processing#parser) to extract only that data from the crawled pages before passing the data to other components. When used in **Tool Mode** with an **Agent** component, the **URL** component can be connected directly to the **Agent** component's **Tools** port without converting the data. diff --git a/docs/docs/Components/components-logic.mdx b/docs/docs/Components/components-logic.mdx index 6c0389561..61e451ec5 100644 --- a/docs/docs/Components/components-logic.mdx +++ b/docs/docs/Components/components-logic.mdx @@ -33,7 +33,10 @@ The following example uses the **If-Else** component to check incoming chat mess 1. Add an **If-Else** component to your flow, and then configure it as follows: - * **Text Input**: Connect the **Text Input** port to a **Chat Input** component. + * **Text Input**: Connect the **Text Input** port to a **Chat Input** component or another `Message` input. + + If your input isn't in `Message` format, you can use another component to transform it, such as the [**Type Convert** component](/components-processing#type-convert) or [**Parser** component](/components-processing#parser). + If your input isn't appropriate for `Message` format, consider using another component for conditional routing, such as the [**Data Operations** component](/components-processing#data-operations). * **Match Text**: Enter `.*(urgent|warning|caution).*` so the component looks for these values in incoming input. The regex match is case sensitive, so if you need to look for all permutations of `warning`, enter `warning|Warning|WARNING`. @@ -96,7 +99,10 @@ You can toggle parameters through the -Loop example +### Loop example In the follow example, the **Loop** component iterates over a CSV file until there are no rows left to process. In this case, the **Item** port passes each row to a **Type Convert** component to convert the row into a `Message` object, passes the `Message` to a **Structured Output** component to be processed into structured data that is then passed back to the **Loop** component's **Looping** port. @@ -145,7 +154,13 @@ After processing all rows, the **Loop** component loads the aggregated list of s For more examples of the **Loop** component, try the **Research Translation Loop** template in Langflow, or see the video tutorial [Mastering the Loop Component & Agentic RAG in Langflow](https://www.youtube.com/watch?v=9Wx7WODSKTo). ::: - +### Conditional looping + +The **If-Else** component isn't compatible with the **Loop** component. +If you need conditional loop events, redesign your flow to process conditions before the loop. +For example, if you are looping over a `DataFrame`, you could use multiple [**DataFrame Operations** components](/components-processing#dataframe-operations) to conditionally filter data, and then run separate loops on each set of filtered data. + +![A flow with conditional looping.](/img/conditional-looping.png) ## Notify and Listen diff --git a/docs/docs/Components/components-processing.mdx b/docs/docs/Components/components-processing.mdx index ca2c1ec43..9855077fe 100644 --- a/docs/docs/Components/components-processing.mdx +++ b/docs/docs/Components/components-processing.mdx @@ -4,6 +4,8 @@ slug: /components-processing --- import Icon from "@site/src/components/icon"; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; Langflow's **Processing** components process and transform data within a flow. They have many uses, including: @@ -11,7 +13,7 @@ They have many uses, including: * Feed instructions and context to your LLMs and agents with the [**Prompt Template** component](#prompt-template). * Extract content from larger chunks of data with a [**Parser** component](#parser). * Filter data with natural language with the [**Smart Function** component](#smart-function). -* Save data to your local machine with the [**Save To File** component](#save-to-file). +* Save data to your local machine with the [**Save File** component](#save-file). * Transform data into a different data type with the [**Type Convert** component](#type-convert) to pass it between incompatible components. ## Prompt Template @@ -21,8 +23,7 @@ See [Prompt Template](/components-prompts). ## Batch Run The **Batch Run** component runs a language model over _each row of one text column_ in a [`DataFrame`](/data-types#dataframe), and then returns a new `DataFrame` with the original text and an LLM response. - -The response contains the following columns: +The output contains the following columns: * `text_input`: The original text from the input `DataFrame` * `model_response`: The model's response for each input @@ -31,7 +32,7 @@ The response contains the following columns: ### Use the Batch Run component in a flow -If you pass this output to a [**Parser** component](/components-processing#parser), you can use variables in the parsing template to reference these keys, such as `{text_input}` and `{model_response}`. +If you pass the **Batch Run** output to a [**Parser** component](/components-processing#parser), you can use variables in the parsing template to reference these keys, such as `{text_input}` and `{model_response}`. This is demonstrated in the following example. ![A batch run component connected to OpenAI and a Parser](/img/component-batch-run.png) @@ -57,7 +58,7 @@ For example, `Create a business card for each name.` record_number: {batch_index}, name: {text_input}, summary: {model_response} ``` -7. To test the processing, click the **Parser** component, and then click **Run component**, and then click **Inspect output** to view the final `DataFrame`. +7. To test the processing, click the **Parser** component, click **Run component**, and then click **Inspect output** to view the final `DataFrame`. You can also connect a **Chat Output** component to the **Parser** component if you want to see the output in the **Playground**. @@ -78,26 +79,41 @@ You can toggle parameters through the **Add more**. +3. Under **Select Keys**, add keys for `name`, `username`, and `email`. +Click **Add more** to add a field for each key. -4. Connect a **Chat Output** component. + 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. ![A flow with Webhook, Data Operations, and Chat Output components](/img/component-data-operations-select-key.png) -5. To test the flow, send the following request to your flow's webhook endpoint, and then open the **Playground** to see the resulting output from processing the payload. +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](/webhook). ```bash curl -X POST "http://$LANGFLOW_SERVER_URL/api/v1/webhook/$FLOW_ID" \ @@ -128,15 +144,19 @@ For this example, select the **Select Keys** operation to extract specific user }' ``` +6. To view the `Data` resulting from the **Select Keys** operation, do one of the following: + + * If you attached a **Chat Output** component, open the **Playground** to see the result as a chat message. + * Click