Skip to content

Commit

Permalink
0.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Fuxa committed Dec 15, 2024
1 parent 2cc6a58 commit 0538371
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
17 changes: 3 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
# RAGHandler for PostgreSQL
# RAGHandler for PostgreSQL with pgvector

A **Retrieval-Augmented Generation (RAG)** handler class built around a PostgreSQL database and OpenAI’s API. This code allows you to query a database, generate vector embeddings for columns, and integrate these operations with a conversational Large Language Model (LLM), such as GPT.

## Features

- **System Prompt Generation:** Automates the creation of a system prompt that describes your PostgreSQL table schema and sample rows.

- **Sophisticated SQL Execution**: Runs multi-step queries with pgvector embeddings for semantic search and filtering.

- **SQL Execution & Vector Replacement**: Executes SQL queries directly against the database. If the SQL query contains <vector>TEXT<vector/> placeholders, those placeholders are replaced with vector embeddings generated via OpenAI.

- **Chat-Based Interaction:** Supports a chat-based workflow by combining user messages, system prompts, and LLM responses. Integrates function calls for:

- Executing SQL queries (execute_sql_query),
- Structuring objects for potential insertion (structure_object_from_draft),
- Generating Plotly graphs (plot_graph).

- **Schema Summarization**: Summarizes a database table’s schema by prompting the LLM, providing a quick overview of column purposes and example values.

- **Object Structuring**: Helps transform free-form text “drafts” into structured objects (e.g., JSON) for database insertion.

- **Embedding Integration**: Automatically generates and stores vector embeddings for specified text columns when creating or replacing tables.
- **Plotly Graph Generation**: Helps transform free-form text “drafts” into structured objects (e.g., JSON) for database insertion.


## Installation
Expand Down
2 changes: 2 additions & 0 deletions rag_handler/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# __init__.py
from .rag_handler import RAGHandler, VECTOR
File renamed without changes.
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from setuptools import setup, find_packages

setup(
name='rag-handler',
version='0.1.0',
description='Retrieval-Augmented Generation Handler using PostgreSQL and OpenAI',
author='Quentin Fuxa',
packages=find_packages(),
install_requires=[
'openai',
'pandas',
'psycopg2',
'sqlalchemy',
'plotly'
],
python_requires='>=3.9'
)

0 comments on commit 0538371

Please sign in to comment.