natural-language-postgres  by vercel-labs

Next.js app for natural language querying of PostgreSQL

Created 11 months ago
271 stars

Top 95.0% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a Next.js application for querying PostgreSQL databases using natural language, with results visualized in tables and charts. It targets developers and users who need to interact with structured data without writing SQL, offering AI-powered query generation, explanation, and automatic chart configuration.

How It Works

The application leverages OpenAI's GPT-4o model via Vercel's AI SDK to translate natural language queries into executable SQL. The generated SQL is then run against a PostgreSQL database. Results are presented in a tabular format, and an AI-generated configuration is used to render an appropriate chart visualization. Users can also request AI-generated explanations of the SQL queries.

Quick Start & Requirements

  • Install dependencies: pnpm install
  • Environment variables: Requires OPENAI_API_KEY and PostgreSQL connection strings (POSTGRES_URL, etc.) in a .env file.
  • Dataset: Download unicorns.csv from CB Insights and place it in the project root.
  • Seed database: pnpm run seed
  • Start server: pnpm run dev
  • Prerequisites: Node.js, pnpm, PostgreSQL database, OpenAI API key.

Highlighted Details

  • Natural language to SQL conversion using GPT-4o.
  • Automatic data visualization with AI-configured charts (Recharts).
  • AI-generated explanations for generated SQL queries.
  • Built with Next.js, AI SDK, Tailwind CSS, and ShadowUI.

Maintenance & Community

This is a Vercel Labs project, indicating potential for high-quality development and integration with Vercel's ecosystem. Specific community channels or active maintenance signals are not detailed in the README.

Licensing & Compatibility

The project's license is not explicitly stated in the README. Compatibility for commercial use or closed-source linking would depend on the final license.

Limitations & Caveats

The project relies on external services (OpenAI API) which incur costs. The accuracy of AI-generated SQL and chart configurations is dependent on the model's performance and the clarity of the natural language input. The dataset is specific to unicorn companies.

Health Check
Last Commit

9 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
12 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems") and Andreas Jansson Andreas Jansson(Cofounder of Replicate).

natural-sql by cfahlgren1

0%
866
Text-to-SQL LLMs with strong performance
Created 1 year ago
Updated 1 year ago
Feedback? Help us improve.