// the find
Azure-Samples/rag-postgres-openai-python
A RAG app to ask questions about rows in a database table. Deployable on Azure Container Apps with PostgreSQL Flexible Server.
A FastAPI and React chat app that answers questions over the rows of a PostgreSQL table, with the database as the only retrieval store. It is an azd template for teams already on Azure who want Container Apps, managed identity, and Azure OpenAI running on day one.
Retrieval runs inside Postgres: pgvector similarity and full-text search are fused with reciprocal rank fusion, so there is no second vector store to keep in sync with the table. Treating each row as the unit of retrieval also skips the chunking decisions that usually drive RAG quality, which suits questions about structured catalog data. The optional function-calling step turns a constraint like 'climbing gear cheaper than $30' into a WHERE clause and leaves fuzzy intent to the embeddings, which is the right split. The repo also ships evals/ with ground truth, a recorded baseline run, a safety evaluation script, and red-team output, which most sample RAG repos leave out.
The local path quietly assumes Azure. The README says to deploy first because the local app uses OpenAI models, and the Ollama route only works well with llama3.1 because Advanced flow needs function calling. Without a function-calling model you lose the filter feature and have to turn Advanced flow off. Setup is also four toolchains deep (Python, Node 18+ for a frontend build the backend needs before it will start, azd, and PostgreSQL with pgvector), spread across the README and several docs files. Bringing your own table is pushed to docs/customize_data.md, so you will be reading the seeding scripts and models before you can point this at real data. Costs are described only as 'cannot be estimated', and changing the embedding model means re-embedding every row, which the README hints at through the nomic-embed-text note but never states outright.