R T E C H

Custom ChatGPT Query System

Project Overview

A ChatGPT-driven interface that converts natural-language questions into SQL, lets users
review/edit queries, executes them on custom databases, and returns results in plain language

Project Overview

Challenges

  • Accurate SQL generation from free-form language: Translating varied user phrasing into syntactically correct, efficient SQL (including JOINs, aggregates, filters).
  • Handling complex, multi-table queries: Ensuring generated SQL respects relationships, performance constraints, and returns the intended results without over-fetching.
  • Safe user editing and execution: Allowing users to modify generated SQL while preventing accidental destructive queries or syntax/runtime errors.
  • Balancing automation vs. control: Providing a smooth, fast experience for casual users while offering experts the ability to review and refine queries.
  • Extending functionality beyond SQL: Planning to support documents and CSVs introduced formats and retrieval challenges (indexing, schema inference, large-file handling).

Solutions

  • Accurate SQL generation from free-form language: Translating varied user phrasing into syntactically correct, efficient SQL (including JOINs, aggregates, filters).
  • Handling complex, multi-table queries: Ensuring generated SQL respects relationships, performance constraints, and returns the intended results without over-fetching.
  • Safe user editing and execution: Allowing users to modify generated SQL while preventing accidental destructive queries or syntax/runtime errors.
  • Balancing automation vs. control: Providing a smooth, fast experience for casual users while offering experts the ability to review and refine queries.
  • Extending functionality beyond SQL: Planning to support documents and CSVs introduced formats and retrieval challenges (indexing, schema inference, large-file handling).
Solutions

Technology Used

  • Programming Language: Python
  • AI / NLP: ChatGPT API (direct integration; LangChain used during prototyping)
  • Backend: Flask (API layer, validation, execution logic)
  • Frontend: React (query input, SQL preview/editor, results display)
  • Database: MySQL (customer-provided)
  • SQL Generation & Safety: Custom logic for SQL construction, validation, and execution controls (timeouts, read-only defaults, sanitization)
  • Deployment / Scaling: Docker (containerized services)
  • Additional / Planned: Document & CSV query adapters (schema inference, chunking/embedding layers planned)