From 05383715cd64e471bae7a0bb646167fdf4a4b183 Mon Sep 17 00:00:00 2001 From: Quentin Fuxa Date: Sun, 15 Dec 2024 14:00:04 +0100 Subject: [PATCH] 0.1.0 release --- README.md | 17 +++-------------- rag_handler/__init__.py | 2 ++ rag_handler.py => rag_handler/rag_handler.py | 0 setup.py | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 rag_handler/__init__.py rename rag_handler.py => rag_handler/rag_handler.py (100%) create mode 100644 setup.py diff --git a/README.md b/README.md index 4450497..4119148 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 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. @@ -6,20 +6,9 @@ A **Retrieval-Augmented Generation (RAG)** handler class built around a PostgreS - **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 TEXT 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 diff --git a/rag_handler/__init__.py b/rag_handler/__init__.py new file mode 100644 index 0000000..97cc37c --- /dev/null +++ b/rag_handler/__init__.py @@ -0,0 +1,2 @@ +# __init__.py +from .rag_handler import RAGHandler, VECTOR \ No newline at end of file diff --git a/rag_handler.py b/rag_handler/rag_handler.py similarity index 100% rename from rag_handler.py rename to rag_handler/rag_handler.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..948d606 --- /dev/null +++ b/setup.py @@ -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' +) \ No newline at end of file