In this tutorial, we'll learn how to use GPT-4o, OpenAI's latest large language model (LLM), to generate product descriptions for products we have stored in an Airtable base. We'll use an Airtable extension, Data Fetcher, to connect our Airtable base to OpenAI's API and generate descriptions for each product in Airtable.
GPT-4o is the first OpenAI LLM that can accept video, image, text, and audio input at the same time. GPT-4o is also cheaper and faster than GPT-4 Turbo, OpenAI's previous flagship LLM. As OpenAI describes:
GPT-4o is 2x faster, half the price, and has 5x higher rate limits compared to GPT-4 Turbo. We plan to launch support for GPT-4o's new audio and video capabilities to a small group of trusted partners in the API in the coming weeks.
Developers building applications on top of OpenAI’s GPT models will take advantage of GPT-4o's all-in-one vision, text, and audio input capabilities to build more intuitive apps. For now, though, developers can only use GPT-4o's text and vision capabilities, as OpenAI hasn't announced when the audio and video features will be available in the API.
Before we install Data Fetcher, we'll create the table that will hold the products and their descriptions:
1. Create a new table and name it “Products”, or use your existing table.
2. Add the following products under the “Name” field. We’re using shoes in this tutorial, but you can input any product (or anything at all!) you want in the “Name” field.
3. Rename the “Notes” field to “Description”. This is where our product descriptions will be once we’ve generated them.
4. Create a new Grid View called "Needs Description". We'll use this view to filter out all the shoes in the table that don't have a description, which is all the shoes at the moment.
5. Click the Filter button on the toolbar, and add the following filters:
With the table set up, we can move on to Data Fetcher.
1. Add the Data Fetcher extension to your Airtable base.
2. Once you’ve added the extension, sign in to Data Fetcher or sign up if you don’t have an account.
3. Once Data Fetcher opens in your Airtable base, click Create your first request.
1. Select OpenAI under Application. You can search for it or scroll down.
2. Rename the request to “Generate product descriptions”.
3. Put in your OpenAI API key under Authorization. You can generate an API key in your OpenAI account.
4. Under Endpoint, select Create chat message completion.
5. Click Save and Continue in the bottom right corner.
Once you've finished the previous steps, you'll be taken to a new section to continue the configuration.
6. GPT-4o should be automatically selected under Model, so you don't have to change this option.
OpenAI’s API considers the text input it takes from us as messages / prompts. When we send a message to the API, we have to specify the message’s role. OpenAI has three message roles: system, user, and assistant.
The system role tells GPT-4o how to behave and respond to our prompts. Since we want GPT-4o to give us product descriptions of the shoes in the “Products” table, we'll instruct it to be an expert footwear copywriter.
1. Under Messages, type/ paste in this text and press Enter.
system: You are an expert footwear copywriter.
The system message will be added.
2. In the Messages input, below the system message, type this text (Data Fetcher will add the user role prefix automatically):
Generate a short description of a product with the name:
Next, we want to add a reference to our "Name" field in Airtable.
3. Click the + icon on the right-hand side of the input.
4. In the window that opens, select Name under Field, then select Needs description under Run every record in view.
5. Click Confirm.
The window will close and take you back to the request.
6. Click Save and Run in the bottom right corner.
After running the previous steps, Data Fetcher will take you to Response Field Mapping. On this page, you'll map the response data to specific fields in the table.
OpenAI returns several fields, but we're only interested in the “Message” field.
Click the Existing field option under "Message", then select “Description” from the dropdown.
Click Save and Run in the bottom right corner.
Data Fetcher will populate the "Description" field of each record with the response from GPT-4o. Go back to the default grid view in your table, and you should see the generated descriptions.
You can use Data Fetcher's Trigger feature to connect to GPT-4o automatically when there is a new product in our Airtable base. This saves you the effort of manually running the request.
The Trigger feature is available on our paid plans, so you can follow these steps to upgrade and use the feature:
Open the request in Data Fetcher, scroll down to the Schedule / Trigger / Webhook URL tabs, select Trigger, then Upgrade.
Select the paid plan that suits you best and complete the payment process.
Go back to your request in Data Fetcher and click I’ve done this.
Now we need to give Data Fetcher API access to your Airtable base. This allows the GPT-4o Airtable integration to run automatically, even when you are not logged into Airtable. Click + Authorize.
A warning dialog will pop up in Data Fetcher. Click I understand, let's Authorize.
A new window will open, asking you to grant Data Fetcher access to your Airtable base. Click Add a base. Select All current and future bases in all current and future workspaces so you don’t need to authorize Data Fetcher anytime you want to use it on an Airtable base.
Then, click Grant access.
Back in Data Fetcher, we can set up the request trigger. We want to connect to OpenAI whenever a new record is created, so select Record created.
For the Table, select "Products" and for the View select "Needs description". By using the filtered "Needs description" view, we ensure that we'll only create descriptions for products with a value in the "Name" field.
Click Save at the bottom of the screen. The trigger is set up and will use GPT-4o to create a description whenever a new product is added.
That’s all for this tutorial. We hope you’ll do creative things with what you learned here. As other GPT-4o features become available, we’ll have new tutorials for you. Until then, check out the Data Fetcher blog to see other ways Data Fetcher can save you time when working with Airtable.
Jul 25, 2024
•Zayyad Muhammad Sani
•OpenAIJul 18, 2024
•Zayyad Muhammad Sani
•OpenAIPDFJul 5, 2024
•Andy Cloke
•OpenAI