• Stars
    star
    458
  • Rank 95,591 (Top 2 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 1 year ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Experimental extension that brings OpenAI API to your PostgreSQL to run queries in human language.

Postgres <> ChatGPT

Experimental PostgreSQL extension that enables the use of OpenAI GPT API inside PostgreSQL, allowing for queries to be written using natural language.

Demo

Postgres.ChatGPT.mp4

(This demo uses data from the Hacker News and Azure CloudQuery plugins)

How does it work?

The extension sends a subset of the database schema to ChatGPT and asks it to generate a query based on this and the user input.

Before you start

  • Note: This plugins sends schema (without the data) to OpenAI GPT API, so it is not recommended to use it on production databases.
  • Note: This is an experimental plugin and not officially supported by CloudQuery.

Installation

Requires pgx. Install this first:

cargo install --locked cargo-pgx
cargo pgx init

Now you can install the extension:

git clone https://github.com/cloudquery/pg_gpt
cd pg_gpt
export OPENAI_KEY=<YOUR_KEY>
cargo pgx run
# will drop into psql shell
create extension pg_gpt;
set openai.key = '<YOUR OPENAPI API KEY HERE>'; -- set your key
select gpt('show me all open aws s3 buckets');
-- will output the following query, so you can execute it
-- select * from aws_s3_bucket;

Available Functions

  • gpt(text) - Generates a query based on the user input and the full database schema. This works fine for databases with small schemas.
  • gpt_tables(table_pattern, text) - Similar to gpt, but only uses the tables that match the pattern. The pattern is passed to a table_name LIKE query, so % can be used as wildcard.

Installing the extension on an existing Postgres instance

First run:

cargo pgx install

This places the extension in the postgres extensions directory. Then, in your postgres instance, run:

create extension pg_gpt;
set openai.key = '<YOUR OPENAPI API KEY HERE>';
-- proceed to use the extension

Limitations

  • Schema Size - Currently we use gpt-3.5-turbo, which is limited to 4096 tokens. Use gpt_tables to narrow down the set of tables.

More Repositories

1

cloudquery

The open source high performance ELT framework powered by Apache Arrow
Go
5,739
star
2

terraform-aws-cloudquery

Terraform module to deploy cloudquery
HCL
36
star
3

cq-provider-aws

CloudQuery Provider for AWS
Go
29
star
4

plugin-sdk

CloudQuery Go SDK for source and destination plugins
Go
21
star
5

aws

Official AWS security & compliance CloudQuery policy pack
HCL
21
star
6

helm-charts

Helm v3 chart that deploys CloudQuery to a Kubernetes cluster
Smarty
21
star
7

cq-provider-azure

CloudQuery Provider for Azure
Go
11
star
8

setup-cloudquery

Setup CloudQuery CLI in GitHub Actions workflows
TypeScript
9
star
9

cq-provider-k8s

CloudQuery Provider for Kubernetes
Go
9
star
10

cq-provider-gcp

CloudQuery Provider for GCP
Go
8
star
11

cq-provider-sdk

CloudQuery Provider SDK enables building providers to query any service or custom in-house solutions with SQL
Go
8
star
12

sqlite

fork of github.com/go-gorm/sqlite with pure-go implementation modernc.org/sqlite
Go
7
star
13

plugin-sdk-java

CloudQuery Java SDK
Java
5
star
14

terraform-gcp-cloudquery

Deploy CloudQuery on GCP
HCL
5
star
15

python-plugin-template

Python
5
star
16

filetypes

A helper library to create destination file plugins for CloudQuery
Go
4
star
17

plugin-sdk-python

Python SDK for building CloudQuery Plugins
Python
4
star
18

docs

https://docs.cloudquery.io
CSS
4
star
19

.github

The open-source cloud asset inventory powered by SQL.
4
star
20

plugin-pb-python

CloudQuery Plugin Python low level API
Python
3
star
21

cq-provider-template

template repository to create new providers for cloudquery
Go
3
star
22

homebrew-tap

homebrew tap for cloudquery
Ruby
3
star
23

cq-source-simple-analytics

A CloudQuery source plugin for Simple Analytics that loads Simple Analytics data into PostgreSQL, BigQuery, Athena, and many other destinations
Go
3
star
24

plugin-sdk-javascript

TypeScript
3
star
25

cq-provider-terraform

CloudQuery Provider for Terraform state files
Go
3
star
26

cq-policy-core

CloudQuery Policy Packs
HCL
3
star
27

dashboards

Grafana dashboards for CloudQuery ☁️
3
star
28

azure

Moved to https://github.com/cloudquery/cq-provider-azure/tree/main/policies
HCL
3
star
29

cq-provider-digitalocean

Digital Ocean CloudQuery Provider
Go
3
star
30

k8s

Moved to: https://github.com/cloudquery/cq-provider-k8s
HCL
2
star
31

cq-provider-test

Test Provider for CloudQuery
Go
2
star
32

cq-source-plaid

A CloudQuery source plugin for [Plaid](https://plaid.com/)
Go
2
star
33

recipes

Real-world CloudQuery configuration examples
2
star
34

plugin-pb-javascript

CloudQuery Plugin JavaScript low level API
TypeScript
2
star
35

cq-gen

cloudquery provider generator
HCL
2
star
36

cq-provider-okta

CloudQuery Provider for Okta
Go
2
star
37

plugin-pb

protobuf files related to plugin-sdk (https://github.com/cloudquery/plugin-sdk)
2
star
38

cloudquery-api-go

Auto-generated CloudQuery APIs for Go.
Go
2
star
39

api-destination-plugin

api destination plugin for hackathon
Go
1
star
40

cq-provider-openstack

CloudQuery OpenStack Provider
Go
1
star
41

cq-provider-cloudflare

CloudQuery Provider for Cloudflare
Go
1
star
42

codegen

Libraries used for generating or bootstrapping CloudQuery plugins
Go
1
star
43

cloudquerydoc

CloudQuery git backed docs - https://docs.cloudquery.io
1
star
44

plugin-pb-go

Generated Go client and server definitions from github.com/cloudquery/plugin-pb files
Go
1
star
45

plugin-pb-java

CloudQuery Plugin Java low level API
Java
1
star
46

iam-for-aws-orgs

1
star
47

javascript-plugin-template

A starter template for a source plugin using CloudQuery JavaScript SDK
TypeScript
1
star