GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Pramjeetk/AI-Agent-RAG: A production-ready Retrieval-Augmented Generation (RAG) system that combines document processing, vector search, and AI-powered responses. Built with PostgreSQL + pgvector for scalable vector storage and OpenAI GPT for intelligent text generation.

BranchesTags
Open more actions menu

Latest commit

 

History

8 Commits
8 Commits

Folders and files

NameName
Last commit message
Last commit date
data
data
 
 
src
src
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
app-controller.py
app-controller.py
 
 
app.py
app.py
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

RAG System with pgvector

A Retrieval-Augmented Generation (RAG) system using PostgreSQL with pgvector for vector storage and OpenAI for text generation.

Features

  • Document Processing: Supports PDF, TXT, CSV, Excel, Word, and JSON files
  • Vector Storage: PostgreSQL with pgvector extension for efficient similarity search
  • Embeddings: Sentence Transformers for document embeddings
  • LLM Integration: OpenAI GPT models for response generation
  • API Interface: FastAPI REST endpoints
  • Environment Configuration: Secure API key management

Architecture

Untitled-2025-09-19-1221
Documents → Chunking → Embeddings → pgvector → Similarity Search → LLM → Response

Setup

Prerequisites

  • Python 3.11+
  • PostgreSQL 14+
  • pgvector extension

Installation

  1. Clone the repository
git clone <repository-url>
cd AI-Agent-RAG
  1. Install PostgreSQL and pgvector
brew install postgresql@14
brew services start postgresql@14
brew install pgvector
  1. Create database
createdb vectordb
psql vectordb -c "CREATE EXTENSION IF NOT EXISTS vector;"
  1. Install Python dependencies
pip install -r requirements.txt
  1. Configure environment
cp .env.example .env
# Edit .env with your configuration

Environment Variables

DATABASE_URL=postgresql://user@localhost:5432/vectordb
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4o-mini

Usage

Command Line

# Run basic RAG query
python app.py

# Start FastAPI server
python app-controller.py

API Endpoints

POST /chat

{
  "message": "What is attention mechanism?"
}

Response

{
  "reply": "Generated response based on document context..."
}

GET /health

{
  "status": "ok"
}

Adding Documents

Place your documents in the data/ directory. Supported formats:

  • PDF files
  • Text files (.txt)
  • CSV files
  • Excel files (.xlsx, .xls)
  • Word documents (.docx)
  • JSON files

Project Structure

├── src/
│   ├── data_loader.py      # Document loading and processing
│   ├── embedding.py        # Embedding pipeline
│   ├── vectorstore.py      # pgvector integration
│   └── search.py           # RAG search and summarization
├── data/                   # Document storage
├── app.py                  # CLI interface
├── app-controller.py       # FastAPI server
├── requirements.txt        # Dependencies
├── .env.example           # Environment template
└── README.md              # This file

Key Components

PgVectorStore

  • Manages PostgreSQL connection
  • Handles vector storage and retrieval
  • Supports similarity search with cosine distance

RAGSearch

  • Combines vector search with LLM generation
  • Processes queries and generates contextual responses
  • Configurable top-k results

Data Loader

  • Multi-format document support
  • Automatic text extraction
  • Chunking for optimal embedding

Performance

  • First API call: Builds vector store (slower)
  • Subsequent calls: Uses existing vectors (fast)
  • Vector dimensions: 384 (sentence-transformers)
  • Similarity metric: Cosine distance

Development

Running Tests

python -m pytest

Code Style

black src/
flake8 src/

Troubleshooting

pgvector extension not found

# Build from source
git clone https://github.com/pgvector/pgvector.git
cd pgvector
make && sudo make install

Database connection issues

  • Verify PostgreSQL is running
  • Check DATABASE_URL in .env
  • Ensure database exists

API key errors

  • Verify OPENAI_API_KEY in .env
  • Check API key permissions

License

MIT License - see LICENSE file for details.

About

A production-ready Retrieval-Augmented Generation (RAG) system that combines document processing, vector search, and AI-powered responses. Built with PostgreSQL + pgvector for scalable vector storage and OpenAI GPT for intelligent text generation.

Resources

Readme
GPL-3.0 license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.