Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lmangani/chdb-gpt
Generate chDB and ClickHouse queries with ChatGPT/OpenAI APIs
https://github.com/lmangani/chdb-gpt
chatgpt chdb clickhouse clickhouse-local clickhouse-server gpt openai sql
Last synced: 24 days ago
JSON representation
Generate chDB and ClickHouse queries with ChatGPT/OpenAI APIs
- Host: GitHub
- URL: https://github.com/lmangani/chdb-gpt
- Owner: lmangani
- Created: 2023-07-08T18:48:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-11T13:24:49.000Z (about 1 year ago)
- Last Synced: 2024-10-04T17:47:14.419Z (about 1 month ago)
- Topics: chatgpt, chdb, clickhouse, clickhouse-local, clickhouse-server, gpt, openai, sql
- Language: Python
- Homepage: https://chdb.dev
- Size: 22.5 KB
- Stars: 11
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# chdb-GPT
Generate chDB and ClickHouse queries using natural language with ChatGPT/OpenAI APIs๐ [Run & Clone on Google Colab](https://colab.research.google.com/drive/1pXdgOsgfuY-8Li-vJd3ZvJI08iCOapWY?usp=sharing)
### Status
* Just a toy, hallucinating states ๐
* Needs Prompt fine tuning and hacks
* Do not use this!### Requirements
* `OPENAI_API_KEY`
```bash
export OPENAI_API_KEY {your_openai_token_here}
```### Usage
#### Count local files
```bash
python3 promtp.py "count rows from file data.csv"
```
```sql
SELECT count(*) FROM file('data.csv')
```#### URL Engine, Parquet
```bash
python3 promtp.py "show the top 10 towns from url https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet"
```
```sql
SELECT town, COUNT(*) AS count
FROM url('https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet', 'Parquet')
GROUP BY town
ORDER BY count DESC
LIMIT 10;
```#### โ ๏ธ Pipe query to chdb
```
# python3 -m chdb "$(./prompt.py "count rows from file data.csv" | awk -v FS="(sql|\`\`\`)" '{print $1}')" Pretty
โโโโโโโโโโโ
โ count() โ
โกโโโโโโโโโโฉ
โ 2 โ
โโโโโโโโโโโ
```#### Interactive Mode
```bash
# python3 interactive.pyHi, I'm chdbGPT, an AI assistant that can execute ClickHouse SQL queries for you.
What would you like to know? => show the top 10 towns by price from url https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet
The query returned data for 10 towns. The towns are listed in descending order of price.
The town with the highest price is London, with a price of 337,000,000.
The remaining towns are also in London, with prices ranging from 315,000,000 to 160,000,000.```