natural-language-postgres  by vercel-labs

Next.js app for natural language querying of PostgreSQL

created 9 months ago
255 stars

Top 99.2% 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

7 months ago

Responsiveness

1+ week

Pull Requests (30d)
4
Issues (30d)
0
Star History
39 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.