Notebooks
O
OpenAI
Gpt Action Bigquery

Gpt Action Bigquery

chatgptgpt_actions_libraryopenaigpt-4examplesopenai-apiopenai-cookbook

GPT Action Library: BigQuery

Introduction

This page provides an instruction & guide for developers building a GPT Action for a specific application. Before you proceed, make sure to first familiarize yourself with the following information:

This particular GPT Action provides an overview of how to connect to Google BigQuery, Google Cloud's Analytical Data Warehouse. This Action takes a user’s question, scans the relevant tables to gather the data schema, then writes a SQL query to answer the user’s question.

Note: these instructions return back a functioning SQL statement, rather than the result itself. Currently middleware is required to return back a CSV file – we’ll be posting instructions on an example of that soon

Value + Example Business Use Cases

Value: Users can now leverage ChatGPT's natural language capability to connect directly to BigQuery's DWH.

Example Use Cases:

  • Data scientists can connect to tables and run data analyses using ChatGPT's Data Analysis
  • Citizen data users can ask basic questions of their transactional data
  • Users gain more visibility into their data & potential anomalies

Application Information

Application Key Links

Check out these links from the application before you get started:

Application Prerequisites

Before you get started, make sure you go through the following steps in your application environment:

  • Set up a GCP project
  • Set up a BQ dataset in that GCP project
  • Ensure that the user authenticating into BigQuery via ChatGPT has access to that BQ dataset

ChatGPT Steps

Custom GPT Instructions

Once you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out Getting Started Example to see how this step works in more detail.

[ ]

OpenAPI Schema

Once you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out Getting Started Example to see how this step works in more detail.

[ ]

Authentication Instructions

Below are instructions on setting up authentication with this 3rd party application. Have questions? Check out Getting Started Example to see how this step works in more detail.

Pre-Action Steps

Before you set up authentication in ChatGPT, please take the following steps in the application.

  • Go to the Google Cloud Console
  • Navigate to API & Services > Credentials
  • Create new OAuth credentials (or use an existing one)
  • Locate your OAuth Client ID & Client Secret and store both values securely (see screenshot below)

gptactions_BigQuery_auth.png

In ChatGPT

In ChatGPT, click on "Authentication" and choose "OAuth". Enter in the information below.

Post-Action Steps

Once you've set up authentication in ChatGPT, follow the steps below in the application to finalize the Action.

  • Copy the callback URL from the GPT Action
  • In the “Authorized redirect URIs” (see screenshot above), add your callback URL

FAQ & Troubleshooting

  • Callback URL Error: If you get a callback URL error in ChatGPT, pay close attention to the screenshot above. You need to add the callback URL directly into GCP for the action to authenticate correctly
  • Schema calls the wrong project or dataset: If ChatGPT calls the wrong project or dataset, consider updating your instructions to make it more explicit either (a) which project / dataset should be called or (b) to require the user provide those exact details before it runs the query

Are there integrations that you’d like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and we’ll take a look.