A modern web application built with FastAPI that combines AI-powered question answering with a PostgreSQL database backend.
- 🚀 RESTful API endpoints built with
FastAPIfor high performance and async support - 🗄️ PostgreSQL database integration using
SQLAlchemy ORM - 🤖 AI-powered question answering using
LangChainandOpenAI's GPTmodels - ⚡ CRUD operations for managing questions and answers
- 📚 Automatic API documentation with
OpenAPI/Swagger UI
- FastAPI: Modern, fast web framework for building APIs
- PostgreSQL: Robust relational database for data persistence
- SQLAlchemy: Powerful SQL toolkit and ORM for Python
- LangChain: Framework for developing applications powered by language models
- OpenAI: State-of-the-art GPT models for natural language processing
- Pydantic: Data validation using Python type annotations
The application enables users to:
- 📝 Create and manage questions and answers
- 🤖 Generate AI-powered responses using OpenAI's language models
- 💾 Store and retrieve QA pairs from PostgreSQL database
- 🔄 Perform full CRUD operations through RESTful endpoints
-
PostgreSQL Server
- Download and register server on PostgreSQL
- Configure database connection in
database.py
-
OpenAI API Key
- Create an OpenAI API key
- Add it to
langchain_answers.py
-
Install dependencies:
# Import all directories from pyproject.toml poetry install -
Navigate to project directory:
cd FastAPIApplication -
Start the server:
uvicorn main:app --reload
-
View API documentation:
- Open your browser and go to
http://127.0.0.1:8000/docs - Interactive Swagger UI will be available for testing endpoints
- Inside the
caller.ipynbyou can also call endpoints through the local session
- Open your browser and go to
- Ensure all environment variables are properly set
- Check database connection before starting the application
- Make sure OpenAI API key is valid and has sufficient credits