ChatGPT plugins let you plug in your custom APIs to enable OpenAI to talk to your company data and take actions via triggering API calls. The integration is pretty seamless; you write a manifest file and explain when ChatGPT should call your plugin. The manifest file has a reference to your OpenAPI spec which includes your API endpoints and ChatGPT automagically generates an API call and calls your API when you ask questions.
The generative AI models usually don't have access to real-time data, they need to be trained in advance. As of today, ChatGPT's cutoff date is 2021 which means that it doesn't know what happened after 2021. The only way for it to access the real-time and private data is through the ChatGPT Plugins. Jinjat helps you connect your data in your data warehouse to ChatGPT. Here are the steps:
You can find the source code here of our sample ChatGPT plugin here: https://github.com/jinjat-data/jaffle_shop_metrics
Setup manifest file
Create the following file and edit the description about of data source. You can see the documentation about the properties here. Jinjat will serve the files under
/static directory by default so OpenAPI will hit our API running locally.
"name_for_human": "ACME Company Data",
"description_for_human": "Plugin for fetching the company data including business metrics including website, marketing, finance data",
"description_for_model": "Plugin for fetching the company data including business metrics including website, marketing, finance data",
"contact_email": "[email protected]",
Next, we will enable CORS for OpenAI so that it can access Jinjat which is running locally.
That's all! Let's register our app in the plugin store.
Looks like magic, right? ChatGPT was smart enough to find the relevant analyses, generate the API query, fetch it from Jinjat and nicely format it for us.
The data is from 2018 because our source data doesn't actually include anything useful for this year so it's expected. ChatGPT also added a note about the
expenses as we have the relevant description for
- name: expenses
description: Get product expenses for all the company
You can see all the API endpoints / dbt analyses on Github, create new SQL files which will generate an endpoint automatically. Developing a plugin for OpenAI usually requires some prompt engineering to tune for the queries that you expect because OpenAI can get confused if your API contract is complex, it's usually recommended to add notes to your yml files. You can find relevant docs below: