本页面为开发者构建特定应用的 GPT Action 提供说明和指南。在继续之前,请务必先熟悉以下信息
这个特定的 GPT Action 概述了如何连接到 Google BigQuery,即 Google Cloud 的分析数据仓库。此 Action 接收用户的问题,扫描相关表以收集数据模式,然后编写 SQL 查询来回答用户的问题。
注意:这些说明返回的是可用的 SQL 语句,而不是结果本身。目前需要中间件才能返回 CSV 文件 – 我们将尽快发布关于此示例的说明
价值:用户现在可以利用 ChatGPT 的自然语言能力直接连接到 BigQuery 的 DWH。
示例用例:
在开始之前,请查看来自应用的这些链接
在开始之前,请确保在您的应用环境中完成以下步骤
创建自定义 GPT 后,将以下文本复制到“Instructions”面板中。有疑问?请查看入门示例,详细了解此步骤的工作原理。
**Context**: You are an expert at writing BigQuery SQL queries. A user is going to ask you a question.
**Instructions**:
1. No matter the user's question, start by running `runQuery` operation using this query: "SELECT column_name, table_name, data_type, description FROM `{project}.{dataset}.INFORMATION_SCHEMA.COLUMN_FIELD_PATHS`"
-- Assume project = "<insert your default project here>", dataset = "<insert your default dataset here>", unless the user provides different values
-- Remember to include useLegacySql:false in the json output
2. Convert the user's question into a SQL statement that leverages the step above and run the `runQuery` operation on that SQL statement to confirm the query works. Add a limit of 100 rows
3. Now remove the limit of 100 rows and return back the query for the user to see
**Additional Notes**: If the user says "Let's get started", explain that the user can provide a project or dataset, along with a question they want answered. If the user has no ideas, suggest that we have a sample flights dataset they can query - ask if they want you to query that
创建自定义 GPT 后,将以下文本复制到“Actions”面板中。有疑问?请查看入门示例,详细了解此步骤的工作原理。
openapi: 3.1.0
info:
title: BigQuery API
description: API for querying a BigQuery table.
version: 1.0.0
servers:
- url: https://bigquery.googleapis.com/bigquery/v2
description: Google BigQuery API server
paths:
/projects/{projectId}/queries:
post:
operationId: runQuery
summary: Executes a query on a specified BigQuery table.
description: Submits a query to BigQuery and returns the results.
x-openai-isConsequential: false
parameters:
- name: projectId
in: path
required: true
description: The ID of the Google Cloud project.
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
query:
type: string
description: The SQL query string.
useLegacySql:
type: boolean
description: Whether to use legacy SQL.
default: false
responses:
'200':
description: Successful query execution.
content:
application/json:
schema:
type: object
properties:
kind:
type: string
example: "bigquery#queryResponse"
schema:
type: object
description: The schema of the results.
jobReference:
type: object
properties:
projectId:
type: string
jobId:
type: string
rows:
type: array
items:
type: object
properties:
f:
type: array
items:
type: object
properties:
v:
type: string
totalRows:
type: string
description: Total number of rows in the query result.
pageToken:
type: string
description: Token for pagination of query results.
'400':
description: Bad request. The request was invalid.
'401':
description: Unauthorized. Authentication is required.
'403':
description: Forbidden. The request is not allowed.
'404':
description: Not found. The specified resource was not found.
'500':
description: Internal server error. An error occurred while processing the request.
以下是关于如何使用此第三方应用设置身份验证的说明。有疑问?请查看入门示例,详细了解此步骤的工作原理。
在 ChatGPT 中设置身份验证之前,请在应用中执行以下步骤。
在 ChatGPT 中,单击“身份验证”并选择 “OAuth”。输入以下信息。
在 ChatGPT 中设置身份验证后,请按照应用中的以下步骤完成 Action。
您希望我们优先考虑哪些集成?我们的集成中是否存在错误?在我们的 github 中提交 PR 或 issue,我们会查看。