rag-postgres-openai-python  by Azure-Samples

RAG app for querying database table rows using OpenAI

created 1 year ago
399 stars

Top 73.7% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides a web-based chat application for querying PostgreSQL database rows using OpenAI models, targeting developers building RAG applications on Azure. It offers hybrid search capabilities and OpenAI function calling for advanced query filtering, simplifying complex data interactions.

How It Works

The application leverages PostgreSQL with the pgvector extension for hybrid search, combining vector similarity search with full-text search. Reciprocal Rank Fusion (RRF) is used to merge results from both search types. OpenAI's embedding API converts user queries into vectors, and function calling can translate natural language questions into SQL WHERE clauses, enhancing query precision and user experience.

Quick Start & Requirements

  • Installation: Use azd init -t rag-postgres-openai-python followed by azd up for Azure deployment. Local setup requires azd, Node.js 18+, Python 3.9+, PostgreSQL 14+, pgvector, Docker, and Git.
  • Prerequisites: Azure account, Azure OpenAI models (gpt-4o-mini, text-embedding-3-large), and potentially local Ollama for alternative model hosting.
  • Resources: Deployment targets Azure Container Apps, Azure PostgreSQL Flexible Server, and Azure OpenAI.
  • Links: GitHub Codespaces, VS Code Dev Containers, Docs

Highlighted Details

  • Hybrid search using pgvector and full-text search with RRF.
  • OpenAI function calling for natural language to SQL conversion.
  • Managed identity for secure Azure service authentication.
  • Deployable via Azure Developer CLI (azd).

Maintenance & Community

This is an Azure Samples project, indicating official support and integration with Azure services. Further guidance and issue tracking are available via the project's issue tracker.

Licensing & Compatibility

The project is licensed under the MIT License, permitting commercial use and integration with closed-source applications.

Limitations & Caveats

The specified Azure OpenAI models (gpt-4o-mini, text-embedding-3-large) may not be available in all Azure regions. Function calling and specific embedding models are recommended for optimal performance but can be disabled if unavailable.

Health Check
Last commit

1 week ago

Responsiveness

Inactive

Pull Requests (30d)
15
Issues (30d)
6
Star History
41 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.