Olympe
A natural language interface to query databases
Try it here π olym.pe
If you are interested in this project, or just want to discuss, contact me on twitter
π§ It's a proof-of-concept, there is lots of work to be done here... π§
Features
- Support high number of tables
- Syntax support for entities ("Netflix" will match "net-flix")
- Use of database values and types to improve the query generation
Nice to have
- Multiple databases support
- Postgres
- BigQuery (wip)
- Plot results in a table or in a chart depending on the query/results
- Possibility to edit & correct the sql query
- Upload of CSV
- Support multiple profils and organisations
Preview
Tech stack
- AI based on OpenAI's GPT-3 API
- Frontend: Vue3, Vite
- Backend: NestJS
- Database: Postgres
- Upload Service: sanic (python)
Code structure
βββ service: backend in nestjs
β βββ src/databases
β β βββ implementatons (postgres, bigquery)
β βββ src/files
β βββ src/queries
β βββ src/tables
β βββ src/users
βββ uploader: micro service to upload data to the playground
βββ view: frontend in vue3
Setup
Back-end
in /service
- create a
.env
file with the following content:
OPENAI_API_KEY=sk-...
DATABASE_URL=postgres://...
yarn
-- install dependenciesyarn typeorm migration:run
-- run migrationsyarn start:dev
-- run the backend
Front-end
in /view
yarn
-- install dependenciesyarn dev
-- run the front
Database
You will need to add a database to start using the service
Upload service
Check README.md in /uploader
for more details
Auth (optional)
You can add users management with Propelauth by adding the following env variables:
/service/.env
PROPELAUTH_URL=
PROPELAUTH_APIKEY=
PROPELAUTH_VERIFIER_KEY=
PROPELAUTH_ISSUER=
/view/.env
VITE_PROPELAUTH_URL=
Docker compose (alternative)
If you prefer to use docker-compose, you can use the following command:
docker-compose up --build
You can modify the docker-compose.yml
file to add variables or modify the database url.
NL2SQL pipeline
- getDatabaseSchema
- selectTables (openai.select_tables.ejs)
- extractConditionsValues (openai.where.ejs)
- fetchClosedValues (from database)
- getValidatedQueriesExamplesOnDatabase (openai.default.ejs)