Skip to main content

How to create and host (for free!) a ChatGPT Plugin using RAW

ChatGPT has revolutionized the way we interact with machines, offering a conversational interface to complex tasks. However, its power can be further amplified by integrating it with external data sources and services. This is where RAW comes into play. By creating a ChatGPT plugin using RAW, developers can seamlessly integrate custom data sources, making ChatGPT even more versatile and powerful.

info

To follow this guide, you need a RAW account which you can create and use for free here.

How Does It Work?

Here's a brief overview of the process to create a ChatGPT plugin.

  • Create Endpoints in RAW: These endpoints will serve as the data sources or services that ChatGPT will interact with.
  • Enable the ChatGPT Support in RAW: Once enabled, the RAW platform will automatically generate the manifest file required by ChatGPT. All public endpoints you create will then be available for ChatGPT to access.
  • Install the plugin in ChatGPT: The final step is to install the newly-created endpoint inside ChatGPT so that it is ready to use.

Example: Creating an Endpoint for Airport Information in RAW

Let's walk through the process of creating an endpoint that provides information about airports.

First, we should create a free account in RAW:


Once you login to RAW, you should head up to the 'Workspace' section as shown below.

Choose the workspace

Then, click on 'Add +' to create a new endpoint and choose a new 'Blank Endpoint' as shown below. You could also choose an existing template, but for this example, let's start blank and write the code ourselves.

Create blank endpoint

Write the endpoint code

Now that you have a blank endpoint, let's start writing some code.

Step 1: Write the code

In RAW, endpoints are written in Snapi, a simple-to-use programming language specifically created specifically for building APIs. You will see this is very simple to create.

Let's copy/paste the following code for our endpoint (see figure, as step '1'):

main(country: string) =
let
airports = Csv.InferAndRead(
"https://raw-tutorial.s3.eu-west-1.amazonaws.com/airports.csv"),
searchCountry = String.Capitalize(country)
in
Collection.Filter(
airports,
a -> String.Capitalize(a.Country) == searchCountry)

// The following test will run if you press the play button.
main("Portugal")

This API receives a single argument country and then searches for matching rows in a CSV file. The last line is just a test to run from the UI.

Step 2: Edit the metadata

ChatGPT needs to know when to use your endpoint. The endpoint metadata (shown in the figure as step '4') is important for this, as it helps the system determine when to use your endpoint. Provide a simple but clear description, e.g.:

  • Title: Airport information
  • Description: Provide information on an airport given a country name.

Here is how the completed endpoint looks like:

Completed endpoint for ChatGPT

Step 3: Test the code

Next, let's test the code. Click on the play button and you will have a live preview of the result of calling the last line of the code.

Step 4: Choose the final URL

You can choose the exact path where your API will be hosted. You can just use the default or choose a different URL.

Step 5: Deploy the endpoint live!

We are almost done. Now click to "Deploy" your endpoint.

Congratulations, your API is now published! It will be served right away and visible in the API Catalog as well.

Enabling the ChatGPT Plugin support in RAW

Now we must enable the ChatGPT Plugin in RAW.

Once this is done, all public endpoints of your newly-created RAW organization will be available to query from ChatGPT.

For this:

  1. Navigate to the "Plugins" section found in the User menu on the top-right corner.
  2. Click on the "ChatGPT Plugin".
  3. Provide a short name for the plugin. Remember, it should not contain any underscores, e.g. "airports" for example.
  4. Add a brief description for the plugin, ensuring it doesn't exceed 50 characters, e.g. "Provide information on airports"
  5. Click on the "Activate" button.

ChatGPT Plugin description in RAW

Upon activation, the RAW platform will publish a manifest file, which is essential for the ChatGPT plugin integration.

ChatGPT Plugin description in RAW

Installing and using the ChatGPT Plugin

The final step is installing and using this plugin from ChatGPT. As of the time of writing (summer 2023), ChatGPT Plugin development is on a wait list and provided only to selected ChatGPT Plus users. Consult the latest updates for more information.

Assuming you have access to ChatGPT plugins for development, do the following:

  1. In ChatGPT, create a New Chat.
  2. Choose GPT-4. Then click on the dropdown and choose "Plugins".
  3. In the "Plugin Store" page, click on "Develop your own plugin". This option is shown in the bottom-right of the window. If it is not visible, you may not yet have access to ChatGPT plugins for development and must join the waiting list of OpenAI
  4. Enter the domain name of your RAW organization. This is the base domain for all your APIs in RAW and it will look like e.g., dev-xyz.api.raw-labs.com. You will also find this name in the "Home" section in RAW under "API URL".
  5. Click "Find Plugin". ChatGPT will then scan your plugin in RAW and report any errors. For instance, if you are missing descriptions or they are too long, you will see such notifications. In case there is any error, go to RAW, edit the metadata and try again.
  6. Now, you're all set to interact with your new plugin!

Installing the ChatGPT Plugin

You can now ask ChatGPT questions related to the API you built. For instance:

Using ChatGPT Plugin

Caveats and Considerations

  • Plugin Name/Description: These are crucial as ChatGPT uses them to determine when to use your plugin. Ensure they are relevant and descriptive.

  • Endpoint Descriptions: The description of each endpoint should be clear and concise, providing a brief overview of its functionality.

  • Constraints: Be mindful of the size constraints, especially in the description field. Adhering to these constraints ensures smooth integration and user experience.

In conclusion, the RAW platform offers a streamlined process to extend ChatGPT's capabilities. By integrating custom data sources and services, developers can harness the full potential of conversational AI.