Your objective determines how you should build in Less
In this exercise, you’ll work with OpenAI to generate product reviews score with artificial intelligence. It can sound complex but the intention with the exercise is to show you how easy anyone can begin creating value with AI. We only use 10 tools to complete this exercise.
You’ll learn tool such as API, Text Column and Parse Data
There are hints to help you get through this exercise. You can also download our solution model and import it in your own model. The file are available at the end of this page.
AI is currently very topical in the data space but it can be difficult to operationalize. We’re going to do that in this exercise. The exercise is about generating a review score column with OpenAI. You’re going to be working with Amazon Tap product reviews. This exercise is relatively simple in terms of the number of actions you’ll be using. The purpose is to build confidence in using the API action and showing how easy it is to start building with AI.
This exercises involves setting up an OpenAI account. Before you worry about costs, the workflow you’ll end up building cost approx. 0.0015USD to run.
Create a new connection. Search for “exercise” and select the AI-Driven Product Review. Configure the connector and you should have access to the tables from the Canvas.
APIs are a method for computers to interact with each other (read more here). In this exercise, we’re going to be interacting with OpenAI’s computers from the inside the Less canvas. The is a very flexible and customizable functionality that opens up a bunch of use cases.
There are many types of API methods (GET, POST, PUT, DELETE, etc). You can think of this as different way of interacting. A GET API call asks the other computer to return some data - you might call Mailchimp’s API to return all your campaigns with a GET call. POST calls - which we will use - asks the other computer to generate something. For instance, you might use a POST call to ask OpenAI to generate an AI review score. You could also use POST calls to create new members in Mailchimp.
You need to configure a couple of things when using API calls. In almost all methods, you need a t l e a s t three components:
/lists/{list_id}/members
to get all your members in the list corresponding to list_id)We’ll be working with a POST API call to OpenAI. You will call using a POST call to the https://api.openai.com/v1/chat/completions
URL with an
Authorization bearer token. You will also add a body which
tell the computer what to create for you.
The body consist of two things specific to OpenAI. This will be familiar if you used ChatGPT. We’re sending a prompt to OpenAI along with some input which in our case is the review data from Amazon.
To the right, you’ll see how this is configured in the API action inside Less. You’ll see that we are referencing columns in Step #3 and #5 (e.g. [token]). In other words, we have a column that contains our authorization bearer token.
The API action on the Less canvas works by sending one API call per row in the dataset. As a result, it will take some time to run the model - e.g. if you have 10.000 rows, you will send 10.000 API calls (which takes time). It’s a good idea to use a Limit action before the API tool while you’re testing to avoid sending too many calls.
You need to create an account and bearer token at OpenAI. Go to https:/ /openai.com/ and create an account. Go to API once you’ve logged in. Once you’re logged in, navigate to Settings and API Keys. Hit the “Create new secret key” and make sure you store the key.
You also need to add funds to OpenAI. You can do that through Settings → Billing → “Add credit balance”. One call with all 30 rows in the reviews dataset costs around 0.0015USD per run. During the entire testing phase while we built this exercise, we spent a total of 0.05USD. So you shouldn’t worry about pricing (unless you start calling the API with millions of rows of data regularly…).
You’re given a dataset with 30 rows. One of the columns is called review_text. This is the one we ask OpenAI to score from 1-10. In a real-life scenario, you might imagine looking the low-scoring reviews to better understand client frustration. Are they frustrated about packaging? Delivery? Features? Pricing? You could also experiment with doing this with OpenAI…
You need to come up with a prompt for OpenAI. We used the one below, but you can experiment with what works for you. To parse the result from OpenAI, you should take a look at the Parse JSON action.
If you need any help from us, please reach out through the in-app support in the bottom, right-hand corner.
Less Prompt
You are to evaluate the product reviews data on a scale from 0-10 where 10 is an absolute fantastic review and 1 is a horrible review. The product is a bluetooth speaker called Amazon Tap. ONLY OUTPUT AN INTERGER NUMBER BETWEEN 1 AND 10 (inclusive).
The table below is the result. We built it with 15 tools. The AI_review_score column is the one we created with AI.
Hint #1
The part of this exercise is about creating our prompt and authentication token. The prompt is basically what we ask the AI do - exactly the same as using ChatGPT.
We add two new columns with two Text Column tools. We call the first column Prompt and the second Token.
In the prompt, we input the below text. You can and should experiment with this to get the results you want. This is known as Prompt Engineering (fancy word for something straightforward…).
You are to evaluate the product reviews data on a scale from 0-10 where 10 is an absolute fantastic review and 1 is a horrible review. The product is a bluetooth speaker called Amazon Tap. ONLY OUTPUT AN INTERGER NUMBER BETWEEN 1 AND 10 (inclusive).
In the Token column, we input our OpenAI API Key. Follow the steps in the Introduction Presentation to generate you own.
Hint #2
The second part is where the magic happens. We use an API tool to call OpenAI and generate our product review scores.
The configuration of the API tools is shown below.
Hint #3
After calling the API we get a couple of new columns - some of which are structured as JSON. JSON looks a bit unfamiliar but we can make it familiar with the Parse JSON tool.
Before doing that we remove all rows that are where Response Status is not equal to 200. Response Status == 200 means that it was successful and we only want those.
Then we go into the Parse JSON, where we essentially parse through the nested layers/levels that are in the response result column. We give the Parse JSON an ID Column in #1 (use the review_id), the in #2 we give it what column what want to parse and in #3 we give it the number of level we want to parse. JSON data is often comprised of levels of data that are nested. You can read more about JSON format here. For now, go with 2 in the first Parse JSON and then 2 again in the second Parse JSON tool while parsing into the choices column.
Hint #4
In the final part, we remove all the columns except the review_id and the content column which we in Tool ID 6. In the Combine, we merge our original dataset using the review_id column, so we have all our original data an our newly create AI generated review score. In Tool ID 10, we rename our content column, AI_review_score and we are done!
This is our full model.
Hint #5
You can very easily calculate the cost of your API call by doing the below if you want.
First, add the prompt_tokens and completion_tokens to the selected columns in the Change Columns tool (Tool ID 6). Secondly, use this formula in a Calculate tool (([sum_prompt_tokens]/1000)*0.0005)+(([sum_completion_tokens]/1000)*0.0015)
Download the solution file here and see how to import it below. Remember to import it in a new model.
Your objective determines how you should build in Less
In this exercise, you’ll work with OpenAI to generate product reviews score with artificial intelligence. It can sound complex but the intention with the exercise is to show you how easy anyone can begin creating value with AI. We only use 10 tools to complete this exercise.
You’ll learn tool such as API, Text Column and Parse Data
There are hints to help you get through this exercise. You can also download our solution model and import it in your own model. The file are available at the end of this page.
AI is currently very topical in the data space but it can be difficult to operationalize. We’re going to do that in this exercise. The exercise is about generating a review score column with OpenAI. You’re going to be working with Amazon Tap product reviews. This exercise is relatively simple in terms of the number of actions you’ll be using. The purpose is to build confidence in using the API action and showing how easy it is to start building with AI.
This exercises involves setting up an OpenAI account. Before you worry about costs, the workflow you’ll end up building cost approx. 0.0015USD to run.
Create a new connection. Search for “exercise” and select the AI-Driven Product Review. Configure the connector and you should have access to the tables from the Canvas.
APIs are a method for computers to interact with each other (read more here). In this exercise, we’re going to be interacting with OpenAI’s computers from the inside the Less canvas. The is a very flexible and customizable functionality that opens up a bunch of use cases.
There are many types of API methods (GET, POST, PUT, DELETE, etc). You can think of this as different way of interacting. A GET API call asks the other computer to return some data - you might call Mailchimp’s API to return all your campaigns with a GET call. POST calls - which we will use - asks the other computer to generate something. For instance, you might use a POST call to ask OpenAI to generate an AI review score. You could also use POST calls to create new members in Mailchimp.
You need to configure a couple of things when using API calls. In almost all methods, you need a t l e a s t three components:
/lists/{list_id}/members
to get all your members in the list corresponding to list_id)We’ll be working with a POST API call to OpenAI. You will call using a POST call to the https://api.openai.com/v1/chat/completions
URL with an
Authorization bearer token. You will also add a body which
tell the computer what to create for you.
The body consist of two things specific to OpenAI. This will be familiar if you used ChatGPT. We’re sending a prompt to OpenAI along with some input which in our case is the review data from Amazon.
To the right, you’ll see how this is configured in the API action inside Less. You’ll see that we are referencing columns in Step #3 and #5 (e.g. [token]). In other words, we have a column that contains our authorization bearer token.
The API action on the Less canvas works by sending one API call per row in the dataset. As a result, it will take some time to run the model - e.g. if you have 10.000 rows, you will send 10.000 API calls (which takes time). It’s a good idea to use a Limit action before the API tool while you’re testing to avoid sending too many calls.
You need to create an account and bearer token at OpenAI. Go to https:/ /openai.com/ and create an account. Go to API once you’ve logged in. Once you’re logged in, navigate to Settings and API Keys. Hit the “Create new secret key” and make sure you store the key.
You also need to add funds to OpenAI. You can do that through Settings → Billing → “Add credit balance”. One call with all 30 rows in the reviews dataset costs around 0.0015USD per run. During the entire testing phase while we built this exercise, we spent a total of 0.05USD. So you shouldn’t worry about pricing (unless you start calling the API with millions of rows of data regularly…).
You’re given a dataset with 30 rows. One of the columns is called review_text. This is the one we ask OpenAI to score from 1-10. In a real-life scenario, you might imagine looking the low-scoring reviews to better understand client frustration. Are they frustrated about packaging? Delivery? Features? Pricing? You could also experiment with doing this with OpenAI…
You need to come up with a prompt for OpenAI. We used the one below, but you can experiment with what works for you. To parse the result from OpenAI, you should take a look at the Parse JSON action.
If you need any help from us, please reach out through the in-app support in the bottom, right-hand corner.
Less Prompt
You are to evaluate the product reviews data on a scale from 0-10 where 10 is an absolute fantastic review and 1 is a horrible review. The product is a bluetooth speaker called Amazon Tap. ONLY OUTPUT AN INTERGER NUMBER BETWEEN 1 AND 10 (inclusive).
The table below is the result. We built it with 15 tools. The AI_review_score column is the one we created with AI.
Hint #1
The part of this exercise is about creating our prompt and authentication token. The prompt is basically what we ask the AI do - exactly the same as using ChatGPT.
We add two new columns with two Text Column tools. We call the first column Prompt and the second Token.
In the prompt, we input the below text. You can and should experiment with this to get the results you want. This is known as Prompt Engineering (fancy word for something straightforward…).
You are to evaluate the product reviews data on a scale from 0-10 where 10 is an absolute fantastic review and 1 is a horrible review. The product is a bluetooth speaker called Amazon Tap. ONLY OUTPUT AN INTERGER NUMBER BETWEEN 1 AND 10 (inclusive).
In the Token column, we input our OpenAI API Key. Follow the steps in the Introduction Presentation to generate you own.
Hint #2
The second part is where the magic happens. We use an API tool to call OpenAI and generate our product review scores.
The configuration of the API tools is shown below.
Hint #3
After calling the API we get a couple of new columns - some of which are structured as JSON. JSON looks a bit unfamiliar but we can make it familiar with the Parse JSON tool.
Before doing that we remove all rows that are where Response Status is not equal to 200. Response Status == 200 means that it was successful and we only want those.
Then we go into the Parse JSON, where we essentially parse through the nested layers/levels that are in the response result column. We give the Parse JSON an ID Column in #1 (use the review_id), the in #2 we give it what column what want to parse and in #3 we give it the number of level we want to parse. JSON data is often comprised of levels of data that are nested. You can read more about JSON format here. For now, go with 2 in the first Parse JSON and then 2 again in the second Parse JSON tool while parsing into the choices column.
Hint #4
In the final part, we remove all the columns except the review_id and the content column which we in Tool ID 6. In the Combine, we merge our original dataset using the review_id column, so we have all our original data an our newly create AI generated review score. In Tool ID 10, we rename our content column, AI_review_score and we are done!
This is our full model.
Hint #5
You can very easily calculate the cost of your API call by doing the below if you want.
First, add the prompt_tokens and completion_tokens to the selected columns in the Change Columns tool (Tool ID 6). Secondly, use this formula in a Calculate tool (([sum_prompt_tokens]/1000)*0.0005)+(([sum_completion_tokens]/1000)*0.0015)
Download the solution file here and see how to import it below. Remember to import it in a new model.