Skip to content

musashimiyomoto/rag-system

Repository files navigation

Python 3.11 Code style: black Imports: isort Ruff Pyright CI/CD Pipeline


RAG System

Requirements

  • Python 3.11
  • Poetry
  • Docker and Docker Compose

Quick Start with Makefile

This project includes a comprehensive Makefile that simplifies common development tasks. To see all available commands:

make help

Docker Run

  1. Create .env file:
cp .env.example .env

Add your API keys to the .env file. Open the file in a text editor and add the required variables in the format KEY=value. For example:

CORE_OPENAI_API_KEY=your_openai_api_key_here
CORE_GOOGLE_API_KEY=your_google_api_key_here
CORE_GITHUB_API_KEY=your_github_api_key_here
  1. Build and start the application:
make build

This command will:

  • Automatically copy .env.example to .env if it doesn't exist
  • Build and start the application using Docker Compose

Important: After the .env file is created, you need to add your API keys for the chosen model provider. Edit the .env file and add the required API keys for your selected AI provider (OpenAI, Google, etc.).

  1. Stop the application:
make stop
  1. Access the API documentation:

Development

Setup

  1. Install all dependencies and setup pre-commit hooks:
make install

This command will:

  • Install all project dependencies including development and test dependencies
  • Set up pre-commit hooks for code quality

Available Makefile Commands

Command Description
make help Show all available commands with descriptions
make install Install dependencies and setup pre-commit hooks
make format Format code using black and isort
make check Run code quality checks with ruff and pyright
make test Run tests with coverage reporting
make build Build and start the application with Docker Compose
make stop Stop the Docker Compose services

Development Workflow

  1. Initial setup:
make install
  1. Before committing code:
make format    # Format your code
make check     # Run linting and type checks
make test      # Run tests
  1. Build and test the application:
make build     # Start the application
# Test your changes
make stop      # Stop when done

RAG System Features

The RAG (Retrieval-Augmented Generation) system provides intelligent document processing and chat capabilities:

  1. Document Upload: Upload documents through the /document endpoint for processing and indexing
  2. Document Processing: Documents are automatically processed, chunked, and stored in a vector database (ChromaDB)
  3. Streaming Responses: Real-time streaming chat responses using FastAPI's StreamingResponse
  4. AI Integration: Powered by PydanticAI with support for multiple AI providers (OpenAI, Google)
  5. Session Management: Persistent chat sessions for better user experience
  6. Health Monitoring: Built-in health checks for system monitoring

API Endpoints

  • Health Check:
    • GET /health/liveness - System liveness health status
    • GET /health/readiness - System readiness health status
  • Document Management:
    • POST /document - Upload and process documents
    • GET /document/list - Get all documents
    • GET /document/{document_id} - Get a specific document
    • GET /document/{document_id}/session/list - Get all sessions for a specific document
    • DELETE /document/{document_id} - Delete a specific document
  • Chat Streaming:
    • POST /chat/stream - Stream chat responses
  • Session Management:
    • POST /session - Create chat sessions
    • DELETE /session/{session_id} - Delete a specific session
    • GET /session/{session_id}/message/list - Get all messages for a specific session
  • Web Interface:
    • GET / - Main application interface
    • GET /chat/{document_id} - Chat interface for specific documents

About

RAG System (FastApi + Pydantic AI + Prefect + ChromaDB + Postgres + Redis)

Resources

Stars

Watchers

Forks