Ask Your PMO-DB is an AI-powered application that allows users to interact with their PostgreSQL database using natural language queries. It integrates OpenAI's ChatGPT to translate plain English questions into SQL queries, providing answers directly from your database.
- OpenAI ChatGPT Integration : Utilize the power of OpenAI's language models to ask complex questions about your PostgreSQL data in natural language.
- Real-Time Querying : Retrieve up-to-date information directly from your PostgreSQL database.
- Easy Configuration : Configure database settings and AI models via a simple
yourConfig.json
file. - Local Development Support : Easily run the application in your local environment using
pnpm
.
Before setting up the application, make sure the following are installed:
- pnpm : Fast and efficient package manager.
- Node.js : Ensure that Node.js is installed on your machine.
- PostgreSQL : A running PostgreSQL instance to connect to.
- OpenAI API Key : You will need an API key from OpenAI to use their ChatGPT model.
To set up the project for local development, follow the instructions below:
Clone this repository to your local machine:
bashCopy codegit clone https://github.com/your-username/ask-your-pmo-db.git cd ask-your-pmo-db
The project uses pnpm
for managing dependencies. If you don't have pnpm
installed, you can install it globally via npm:
bashCopy codenpm install -g pnpm
Then, install the project dependencies:
bashCopy codepnpm install
Create a configuration file named yourConfig.json
in the root directory. This file will include your database credentials and OpenAI API key.
Example yourConfig.json
:
jsonCopy code{ "database": { "host": "localhost", "port": 5432, "user": "your_db_user", "password": "your_db_password", "dbname": "your_db_name" }, "openai": { "api_key": "your_openai_api_key", "model": "gpt-4" } }
To start the application, use the following command and pass the configuration file as an argument:
bashCopy codepnpm start yourConfig.json
This will start the service, enabling you to interact with your PostgreSQL database via natural language questions powered by OpenAI's ChatGPT.
Once the application is up and running, you can use the AI model to query your PostgreSQL database. Just ask questions in plain language, and the AI will generate and execute the appropriate SQL queries.
Example questions:
- "What are the top 5 projects by budget?"
- "How many open tasks are there for project X?"
- "Which employees have overdue tasks?"
For additional flexibility, you can also set environment variables to override the configuration:
DB_HOST
: The PostgreSQL host (default:localhost
).DB_PORT
: The PostgreSQL port (default:5432
).DB_USER
: The PostgreSQL user.DB_PASSWORD
: The PostgreSQL password.DB_NAME
: The name of the PostgreSQL database.OPENAI_API_KEY
: Your OpenAI API key.