Repolode
Azure-Samples

Azure-Samples/rag-postgres-openai-python

A RAG chat app that answers natural-language questions about rows in a PostgreSQL table, using pgvector search and OpenAI models, deployable to Azure.

Stars
508
Forks
1,060
Open issues
63
Last commit
14 hours ago

What is it?

This project is a web-based chat application that answers questions about the rows of a PostgreSQL database table. It has a React and FluentUI frontend and a Python FastAPI backend. Retrieval combines pgvector vector search with PostgreSQL full text search, merging the two result lists with Reciprocal Rank Fusion (RRF).

User questions can be turned into query filter conditions through OpenAI function calling, so a question like "Climbing gear cheaper than $30?" becomes a SQL WHERE clause on price. Query embeddings are produced with the OpenAI embedding API.

The project is designed for deployment on Azure with the Azure Developer CLI. The app runs on Azure Container Apps, the database on Azure Database for PostgreSQL Flexible Server, and models on Azure OpenAI, with managed identity for authentication. It can also run locally against OpenAI.com or Ollama models.

Key features

  • 01Hybrid search combining pgvector vector search and PostgreSQL full text search via RRF
  • 02OpenAI function calling converts natural-language queries into SQL filter conditions
  • 03Query embeddings generated with the OpenAI embedding API
  • 04Deployment to Azure Container Apps and Azure PostgreSQL Flexible Server via azd
  • 05Supports Azure OpenAI, OpenAI.com, and Ollama as model providers

Use cases

  • Building a question-answering chat over a product catalog stored in PostgreSQL
  • Prototyping RAG over relational table data on Azure
  • Learning how to combine pgvector hybrid search with LLM function calling

Quick start

  1. 1

    Download the project code with azd

    azd init -t rag-postgres-openai-python
  2. 2

    Sign in to your Azure account

    azd auth login
  3. 3

    Provision the resources and deploy the code

    azd up

Things to know

  • Deploying to Azure is the intended path and incurs pay-as-you-go costs for Container Apps, Azure OpenAI, PostgreSQL and Azure Monitor.
  • The README recommends deploying first, since local development relies on OpenAI models that you must configure yourself.

In collections

Topics

FAQ

What is rag-postgres-openai-python?
A RAG chat app that answers natural-language questions about rows in a PostgreSQL table, using pgvector search and OpenAI models, deployable to Azure. This project is a web-based chat application that answers questions about the rows of a PostgreSQL database table. It has a React and FluentUI frontend and a Python FastAPI backend. Retrieval combines pgvector vector search with PostgreSQL full text search, merging the two result lists with Reciprocal Rank Fusion (RRF).
Is rag-postgres-openai-python free to use? What license does it have?
rag-postgres-openai-python is open source under the MIT license. Check the license terms before using it in commercial products.
Is rag-postgres-openai-python still maintained?
Actively maintained. The last commit to rag-postgres-openai-python was on Nov 6, 2026.
What can I use rag-postgres-openai-python for?
Building a question-answering chat over a product catalog stored in PostgreSQL Prototyping RAG over relational table data on Azure Learning how to combine pgvector hybrid search with LLM function calling
How do I install rag-postgres-openai-python?
Download the project code with azd: azd init -t rag-postgres-openai-python Sign in to your Azure account: azd auth login Provision the resources and deploy the code: azd up
Where can I get rag-postgres-openai-python?
The source code and installation instructions are on GitHub: https://github.com/Azure-Samples/rag-postgres-openai-python

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects