Skip to content

Repository files navigation

LangChain: sqlAI

License: MIT Python Version Streamlit PostgreSQL


Table of Contents


Overview

LangChain: Postgres AI is an intelligent assistant that allows users to interact with a PostgreSQL database using natural language queries. It leverages the power of LangChain agents and the Groq API for seamless integration with database operations.


Features

  • Natural Language Querying: Translate user queries into SQL and fetch results dynamically.
  • Streamlit Interface: An intuitive web-based UI for interaction.
  • Dynamic Database Integration: Configure and connect to any PostgreSQL database.
  • Error Handling: Robust error detection and informative feedback.
  • Agent-Based Execution: Leverages LangChain Zero-Shot React agents for database queries.

Installation

1. Clone the Repository

git clone https://github.com/your-username/langchain-postgres-ai.git
cd langchain-postgres-ai

2. Create and Activate a Virtual Environment

python3 -m venv venv
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4.Configure PostgreSQL Database

[postgresql]
host=<YOUR_DB_HOST>
database=<YOUR_DB_NAME>
user=<YOUR_DB_USER>
password=<YOUR_DB_PASSWORD>
port=<YOUR_DB_PORT>

Usage

1. Run the script

streamlit run app.py

2. Provide API Key

Input your Groq API key in the sidebar under Groq API Key.

Database Configuration

1. Configure the Database Connection

def connect():
    connection = psycopg2.connect(**config())
    return connection

Querying the Database

1. Chat Input

"how many cehicles in fleet A."

2. Database Results

"The system translates the query into SQL and fetches results from the connected database."

License

"This project is licensed under the MIT License. See the LICENSE file for more details
."

Results

Result1: output Result1: output

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages