Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: langflow ai integration docs #1425

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b378040
initial version
MQ37 Jan 22, 2025
c755777
Merge branch 'master' into feat/langflow-integration
MQ37 Jan 22, 2025
9750cdd
lint
MQ37 Jan 22, 2025
c7bdb40
white theme screens, use openai in example run
MQ37 Jan 23, 2025
bdb3568
add langflow vale exception
MQ37 Jan 23, 2025
019ca47
improve text to align with guidelines
MQ37 Jan 23, 2025
27e2b4f
add section on how to call the actors, improve docs
MQ37 Jan 26, 2025
6c494a5
Merge branch 'master' into feat/langflow-integration
MQ37 Jan 26, 2025
5237737
Update sources/platform/integrations/ai/langflow.md
MQ37 Jan 28, 2025
7bcfd2c
Update sources/platform/integrations/ai/langflow.md
MQ37 Jan 28, 2025
bb8e2f8
Update sources/platform/integrations/ai/langflow.md
MQ37 Jan 28, 2025
c17648d
Update sources/platform/integrations/ai/langflow.md
MQ37 Jan 28, 2025
fa0caf7
Update sources/platform/integrations/ai/langflow.md
MQ37 Jan 28, 2025
457a7e3
remove the separator
MQ37 Jan 28, 2025
b27947f
Merge branch 'master' into feat/langflow-integration
MQ37 Jan 28, 2025
dea7c21
Update sources/platform/integrations/ai/langflow.md
MQ37 Jan 29, 2025
cf05aca
Update sources/platform/integrations/ai/langflow.md
MQ37 Jan 29, 2025
605ac2e
remove new flow screen, split use cases into bullet points, implement…
MQ37 Jan 29, 2025
98360ca
simplify, remove obvious ui steps screens
MQ37 Jan 29, 2025
4be4887
lint
MQ37 Jan 29, 2025
18ca140
add prerequisites section
MQ37 Jan 29, 2025
2b3ded8
rework screens with flatten output wihout question mark, simplify and…
MQ37 Jan 29, 2025
c46739b
fix typos
MQ37 Jan 29, 2025
ed57fa6
unify agent keyword caps, agent -> AI agent, Agent -> component
MQ37 Jan 29, 2025
66275c2
Merge branch 'master' into feat/langflow-integration
MQ37 Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/styles/config/vocabularies/Docs/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ preconfigured
asyncio
parallelization
IMDb


Langflow

iPhone
iPhones
iPad
Expand Down
131 changes: 131 additions & 0 deletions sources/platform/integrations/ai/langflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
title: Langflow integration
sidebar_label: Langflow
description: Learn how to integrate Apify with Langflow low-code tool to build powerful AI agents and workflows that can use any API, model, or database.
sidebar_position: 1
slug: /integrations/langflow
---

**Learn how to integrate Apify with Langflow to run complex AI agent workflows.**

---

## What is Langflow

[Langflow](https://langflow.org/) is a low-code, visual tool that enables developers to build powerful AI agents and workflows that can use any API, models, or databases.

:::note Explore Langflow

For more information on Langflow, visit its [documentation](https://docs.langflow.org/).

:::

## How to use Apify with Langflow

This guide will demonstrate two different ways to use Apify Actors with Langflow:

- **Calling Apify Actors in Langflow**: We will use the [RAG Web Browser](https://apify.com/apify/rag-web-browser) Actor to search Google for a query and extract the search results.
- **Building a flow to search for a company's social media profiles**: We will use the [Google Search Results Scraper](https://apify.com/apify/google-search-scraper) Actor to search the web for social media profiles of a given company. Then, we will use the [TikTok Data Extractor](https://apify.com/clockworks/free-tiktok-scraper) Actor to extract data from the TikTok profiles.

### Prerequisites

#### Apify API token

To use Apify Actors in Langflow, you need an Apify API token. If you don't have one, you can learn how to obtain it in the [Apify documentation](https://docs.apify.com/platform/integrations/api).

#### OpenAI API key

In order to work with agents in Langflow, you need an OpenAI API key. If you don't have one, you can get it from the [OpenAI platform](https://platform.openai.com/account/api-keys).

#### Langflow

:::note Cloud vs local setup

Langflow can either be installed locally or used in the cloud. The cloud version is available on the [Langflow](http://langflow.org/) website. If you are using the cloud version, you can skip the installation step, and go straight to [Creating a new flow](#creating-a-new-flow)

:::

First, we need to install the Langflow platform using python package and project manager [uv](https://docs.astral.sh/uv/):

```bash
uv pip install langflow
```

After successfully installing Langflow, we can start the platform:

```bash
uv run langflow run
```

When the platform is started, open the [Langflow UI](http://127.0.0.1:7860) in your browser.

> Other installation methods can be found in the [Langflow documentation](https://docs.langflow.org/get-started-installation).

### Creating a new flow

On the Langflow welcome screen, click the **New Flow** button and then create **Blank Flow**:
![New Flow screen - Blank Flow](../images/langflow/new_blank_flow.png)

Now, we can start building our flow.

### Calling Apify Actors in Langflow

To call Apify Actors in Langflow, we need to add the **Apify Actors** component to the flow.
From the bundle menu, add **Apify Actors** component:
![Flow - Add Apify Actors](../images/langflow/bundles_apify.png)

Next, we need to configure the Apify Actors components. First, input your API token (learn how to get it [here](https://docs.apify.com/platform/integrations/api)). Then, set the Actor ID of the component to `apify/rag-web-browser` to use the [RAG Web Browser](https://apify.com/apify/rag-web-browser). Set the **Run input** field to pass arguments to the Actor run, allowing it to search Google with the query `"what is monero?"` (full Actor input schema can be found [here](https://apify.com/apify/rag-web-browser/input-schema)):

```json
{"query": "what is monero?", "maxResults": 3}
```

Now, we can run the component by clicking the **Run** button.
![Flow - Apify Actors Run](../images/langflow/apify_actors_run.png)

Once the run is finished, we can view the output by clicking the **Output** button.
![Flow - Apify Actors Output](../images/langflow/apify_actors_output.png)

The output should look similar to this:
![Flow - Apify Actors Output Data](../images/langflow/apify_actors_output_data.png)

To filter only the `metadata` and `markdown` fields, set **Output fields** to `metadata,markdown`. Additionally, enable **Flatten output** by setting it to `true`. This will output only the metadata and text content from the search results.
> Flattening is necessary when you need to access nested dictionary fields in the output data object; they cannot be accessed directly otherwise in the Data object.

![Flow - Apify Actors Output Filter](../images/langflow/apify_actors_output_filter.png)

When you run the component again, the output contains only the `markdown` and flattened `metadata` fields:

![Flow - Apify Actors Output Filtered](../images/langflow/apify_actors_output_data_filtered.png)

Now that we understand how to call Apify Actors, let's build a practical example where we search for a company's social media profiles and extract data from them.

### Building a flow to search for a company's social media profiles

Create a new flow and add two **Apify Actors** components from the menu.

Input your API token (learn how to get it [here](https://docs.apify.com/platform/integrations/api)) and set the Actor ID of the first component to `apify/google-search-scraper` and the second one to `clockworks/free-tiktok-scraper`:
![Flow - Actors configuration](../images/langflow/apify_actors_configuration.png)

Add the **Agent** component from the menu and set your OpenAI API key (get it [here](https://platform.openai.com/account/api-keys)):
:::tip Optimize Agent results

For better results, switch the model to `gpt-4o` instead of `gpt-4o-mini` in the Agent configuration

:::
![Flow - Agent configuration](../images/langflow/agent_configuration.png)

To be able to interact with the agent, add **Chat Input** and **Chat Output** components from the menu and connect them to the Agent component **Input** and **Response**.
Then connect both Apify Actor components **Tool** outputs to the Agent component **Tools** input so that the agent can call the Apify Actors. The final flow that can search the web for a company's social media profiles and extract data from them should look like this:
![Flow - Final](../images/langflow/flow.png)

Click the **Playground** button and chat with the agent to test the flow:
![Flow - Playground](../images/langflow/playground.png)

Here is an example agent output for the following query:

```text
find tiktok profile of company openai using google search and then show me the profile bio and their latest video
```

![Flow - agent output](../images/langflow/agent_output.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading