Skip to content

ai-in-pm/ask-your-pmo-db

Repository files navigation

Ask Your PMO-DB

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.

Features

  • 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.

Prerequisites

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.

Getting Started

To set up the project for local development, follow the instructions below:

1. Clone the Repository

Clone this repository to your local machine:

bash
Copy code
git clone https://github.com/your-username/ask-your-pmo-db.git cd ask-your-pmo-db

2. Install Dependencies

The project uses pnpm for managing dependencies. If you don't have pnpm installed, you can install it globally via npm:

bash
Copy code
npm install -g pnpm

Then, install the project dependencies:

bash
Copy code
pnpm install

3. Set Up Configuration

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:

json
Copy 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" } }

4. Start the Application

To start the application, use the following command and pass the configuration file as an argument:

bash
Copy code
pnpm 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.

Usage

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?"

Environment Variables

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.

About

Ask AI (ChatGPT) to query your PostGreSQL Database

Resources

License

Stars

Watchers

Forks

Packages

No packages published