Beam’s agent framework is designed for concurrency and synchronization. In this example, we’ll show how you can deploy an app that scrapes online product reviews.
You can follow along with the tutorial in the video below.
Beam’s Petri Net framework is ideal for workflows that require concurrency and scalability. This app uses Beam to:
You’ll need three API keys to run the example below:
Set up your environment variables by adding these keys to a .env
file in your project directory.
Locations represent the states of data flowing through the network. In this app, we’ll use three states:
Define these locations in your code:
Let’s setup the bot, which is what manages the workflow. Add your API keys and define the locations (states) it will manage.
Transitions are events or actions in your bot, triggered by changes to the locations (state).
The first transition takes a product category (e.g., “headphones”) and uses SerpAPI to retrieve Google Shopping URLs for the product.
The second transition scrapes review pages from each product URL using Firecrawl.
The final transition summarizes reviews from all the scraped pages into a markdown file.
Pay close attention to the inputs
field below. This transition will not begin running until 3 ReviewPage
markers have been created from the previous transition.
Once deployed, you’ll be able to see the tasks in the dashboard, with the transition waiting until all ReviewPage
markers have been emitted.
Deploying the bot gives you access to a dashboard, where you can interact with the bot using a Chat UI.
With the bot deployed, there are a few things you can try:
You can create a public, sharable Chat Page for your bot by adding an authorized=False
argument to the bot
:
When deployed, this gives you a sharable Chat UI. You can retrieve the URL to the Chat UI by clicking next to the “lock” icon.
Here’s what the Chat UI looks like:
We provide a number of helper commands using a class called context
.
Context variables can be used for prompting the user for input, creating blocking requests to the bot, and sending message to the user.
Available Commands
Method | Description |
---|---|
context.confirm() | Pause a transition until a user says yes or no. |
context.prompt() | Send a blocking or non-blocking request to the model (e.g., “summarize these reviews”). You can pass an optional wait_for_response=False boolean to make this non-blocking. |
context.remember() | Add an arbitrary JSON-serializable object to the conversation memory. |
context.say() | Output text to the user’s chat window. |
context.send_file() | Send a file to the user from a transition. |
context.get_file() | Retrieve a file from the user during a transition. |
You can see the full code for this example below.
View The Code
Beam’s agent framework is designed for concurrency and synchronization. In this example, we’ll show how you can deploy an app that scrapes online product reviews.
You can follow along with the tutorial in the video below.
Beam’s Petri Net framework is ideal for workflows that require concurrency and scalability. This app uses Beam to:
You’ll need three API keys to run the example below:
Set up your environment variables by adding these keys to a .env
file in your project directory.
Locations represent the states of data flowing through the network. In this app, we’ll use three states:
Define these locations in your code:
Let’s setup the bot, which is what manages the workflow. Add your API keys and define the locations (states) it will manage.
Transitions are events or actions in your bot, triggered by changes to the locations (state).
The first transition takes a product category (e.g., “headphones”) and uses SerpAPI to retrieve Google Shopping URLs for the product.
The second transition scrapes review pages from each product URL using Firecrawl.
The final transition summarizes reviews from all the scraped pages into a markdown file.
Pay close attention to the inputs
field below. This transition will not begin running until 3 ReviewPage
markers have been created from the previous transition.
Once deployed, you’ll be able to see the tasks in the dashboard, with the transition waiting until all ReviewPage
markers have been emitted.
Deploying the bot gives you access to a dashboard, where you can interact with the bot using a Chat UI.
With the bot deployed, there are a few things you can try:
You can create a public, sharable Chat Page for your bot by adding an authorized=False
argument to the bot
:
When deployed, this gives you a sharable Chat UI. You can retrieve the URL to the Chat UI by clicking next to the “lock” icon.
Here’s what the Chat UI looks like:
We provide a number of helper commands using a class called context
.
Context variables can be used for prompting the user for input, creating blocking requests to the bot, and sending message to the user.
Available Commands
Method | Description |
---|---|
context.confirm() | Pause a transition until a user says yes or no. |
context.prompt() | Send a blocking or non-blocking request to the model (e.g., “summarize these reviews”). You can pass an optional wait_for_response=False boolean to make this non-blocking. |
context.remember() | Add an arbitrary JSON-serializable object to the conversation memory. |
context.say() | Output text to the user’s chat window. |
context.send_file() | Send a file to the user from a transition. |
context.get_file() | Retrieve a file from the user during a transition. |
You can see the full code for this example below.
View The Code