RAG on PostgreSQL
A sample chat application and FastAPI backend that answers questions about rows in a PostgreSQL table using OpenAI chat models, hybrid vector and full-text search, and function calling to turn natural-language filters into SQL conditions.
This project combines pgvector-based vector search with PostgreSQL full-text search, merging the two result sets with Reciprocal Rank Fusion, and uses OpenAI function calling to convert queries such as "climbing gear cheaper than $30" into query filter conditions. User queries are converted into vectors through the OpenAI embedding API.
The frontend is built with React and FluentUI, and the backend with Python and FastAPI. It is designed for deployment to Azure Container Apps with the Azure Developer CLI, storing data in Azure PostgreSQL Flexible Server and using Azure OpenAI for the models, with a user-assigned managed identity and logs in Log Analytics.
It can be run through GitHub Codespaces, VS Code Dev Containers, or a local environment with Node.js, Python, PostgreSQL, pgvector and Docker Desktop installed.