Skip to main content

A demo project for RAG using FastAPI and LlamaIndex

Project description

Readme

This is a demo project for Retrieval-Augmented Generation (RAG) service based on LlamaIndex and FastAPI. It includes an example of how to set up and use the RAG service with a MinIO storage backend, MongoDB for metadata storage, and Qdrant for vector storage.

Prerequisites

  • Docker and Docker Compose installed on your machine.
  • Python 3.13 or higher installed.
  • Required Python packages listed in pyproject.toml.

Setup

  1. Clone the repository to your local machine.

  2. Install the required Python packages using Pip:

    pip install .
    

    or if you are using uv:

     uv sync
    
  3. Start the MinIO, MongoDB and Qdrant service using Docker Compose:

    cd example
    docker compose up
    

Usage

  1. Modify the configuration in example/config.yaml as needed, especially the LLM settings.

    Note: we use the OpenAI-compatible models.

    Here is an example configuration for the embedding and generation models:

     rag:
         embedding_model:
             model_name: text-embedding-v4
             api_base: https://dashscope.aliyuncs.com/compatible-mode/v1
             api_key: <YOUR_API_KEY>
    
    
         generation_model:
             model_name: qwen3-next-80b-a3b-instruct
             api_base: https://dashscope.aliyuncs.com/compatible-mode/v1
             api_key: <YOUR_API_KEY>
             other_parameters:
                 is_chat_model: true
    
  2. Start the RAG service by running the example/main.py script:

    cd example
    python main.py
    

Test

  • The test.py file contains simple tests for the RAG service functionalities. You can run it:

     python test.py
    
  • The test_rag_service.py file contains unit tests for the RAG service. You can run it using pytest:

     python test_rag_service.py
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

demo_rag-0.0.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

demo_rag-0.0.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file demo_rag-0.0.1.tar.gz.

File metadata

  • Download URL: demo_rag-0.0.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for demo_rag-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9cd715552dd2e7c8e56c6e3379529e8eb94417578030ed018758195dcc4cc42d
MD5 43e59db8e45cda3d7f367772df1ea5ba
BLAKE2b-256 6ed6c248a621c761d1573c48960e0cc7498eeaddd30b54fd402c99e905d63bc2

See more details on using hashes here.

File details

Details for the file demo_rag-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: demo_rag-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for demo_rag-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 519aafd26227b915243ca7cb93f798c932889ce1756d58f6105d21593535d2ab
MD5 137c99d1d3e274542455de8e76b36a2e
BLAKE2b-256 f94637a2c2cd6bed891682fec414ddd73305ff898e1b4e1435ea9c2b331e7d86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page