{"id":15687317,"url":"https://github.com/lmangani/chdb-gpt","last_synced_at":"2025-05-07T19:41:00.715Z","repository":{"id":179734888,"uuid":"664038324","full_name":"lmangani/chdb-GPT","owner":"lmangani","description":"Generate chDB and ClickHouse queries with ChatGPT/OpenAI APIs","archived":false,"fork":false,"pushed_at":"2023-11-11T13:24:49.000Z","size":23,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T13:27:31.505Z","etag":null,"topics":["chatgpt","chdb","clickhouse","clickhouse-local","clickhouse-server","gpt","openai","sql"],"latest_commit_sha":null,"homepage":"https://chdb.dev","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lmangani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-08T18:48:51.000Z","updated_at":"2024-10-24T15:39:39.000Z","dependencies_parsed_at":"2023-11-11T14:26:37.279Z","dependency_job_id":"9f2e4089-7f15-4601-b4a7-00eb8c46602d","html_url":"https://github.com/lmangani/chdb-GPT","commit_stats":null,"previous_names":["lmangani/chdb-gpt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmangani%2Fchdb-GPT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmangani%2Fchdb-GPT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmangani%2Fchdb-GPT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmangani%2Fchdb-GPT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lmangani","download_url":"https://codeload.github.com/lmangani/chdb-GPT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252945143,"owners_count":21829544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","chdb","clickhouse","clickhouse-local","clickhouse-server","gpt","openai","sql"],"created_at":"2024-10-03T17:47:13.400Z","updated_at":"2025-05-07T19:41:00.691Z","avatar_url":"https://github.com/lmangani.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/chdb-io/chdb/raw/pybind/docs/_static/snake-chdb.png\" width=320 \u003e\n\n# chdb-GPT\nGenerate chDB and ClickHouse queries using natural language with ChatGPT/OpenAI APIs\n\n👉 [Run \u0026 Clone on Google Colab](https://colab.research.google.com/drive/1pXdgOsgfuY-8Li-vJd3ZvJI08iCOapWY?usp=sharing)\n\n### Status\n* Just a toy, hallucinating states 🐍\n* Needs Prompt fine tuning and hacks\n* Do not use this!\n\n### Requirements\n* `OPENAI_API_KEY`\n```bash\nexport OPENAI_API_KEY {your_openai_token_here}\n```\n\n### Usage\n#### Count local files\n```bash\npython3 promtp.py \"count rows from file data.csv\"\n```\n```sql\nSELECT count(*) FROM file('data.csv')\n```\n\n#### URL Engine, Parquet\n```bash\npython3 promtp.py \"show the top 10 towns from url https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet\" \n```\n```sql\nSELECT town, COUNT(*) AS count\nFROM url('https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet', 'Parquet')\nGROUP BY town\nORDER BY count DESC\nLIMIT 10;\n```\n\n#### ⚠️ Pipe query to chdb\n```\n# python3 -m chdb \"$(./prompt.py \"count rows from file data.csv\" | awk -v FS=\"(sql|\\`\\`\\`)\" '{print $1}')\" Pretty\n┏━━━━━━━━━┓\n┃ count() ┃\n┡━━━━━━━━━┩\n│       2 │\n└─────────┘\n```\n\n#### Interactive Mode\n\n```bash\n# python3 interactive.py \n\nHi, I'm chdbGPT, an AI assistant that can execute ClickHouse SQL queries for you.\n\nWhat would you like to know? =\u003e show the top 10 towns by price from url https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet\n\nThe query returned data for 10 towns. The towns are listed in descending order of price.\nThe town with the highest price is London, with a price of 337,000,000.\nThe remaining towns are also in London, with prices ranging from 315,000,000 to 160,000,000.\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmangani%2Fchdb-gpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flmangani%2Fchdb-gpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmangani%2Fchdb-gpt/lists"}