Lio is a comprehensive service designed for efficient document processing and interactive chat capabilities powered by retrieval-augmented generation. Leverage the power of advanced retrieval techniques to integrate document context seamlessly into chat interactions for more precise and context-aware responses.
🔄 Architecture Overview: Built on a robust web-queue-worker pattern where FastAPI handles web requests, Redis manages message queues, and Dramatiq workers process background tasks asynchronously. Powered by Qdrant vector database for efficient document storage and retrieval, leveraging Cohere/OpenAI embeddings, and LangChain for seamless AI interactions and document processing pipeline.
- 🎯 Prerequisites
- ⚙️ Setup and Installation
▶️ Running the Application- 👷 Running Background Workers
- 🏗️ Project Structure
Ensure you have the following installed on your system:
- 🐍 Python 3.12.x
- 📦 PDM (Python Dependency Management)
- 🐳 Docker for running Redis
PDM is used to manage Python dependencies. Run the following command to install PDM if it's not already installed:
pip install pdm
Navigate to your project directory and run:
pdm install
This command will create a virtual environment and install the dependencies listed in pyproject.toml
.
Run the following commands to start Redis and Qdrant services:
Start Redis:
docker run --name redis_container -p 6379:6379 -d redis:latest
These commands will download the Redis and Qdrant images (if not already available) and start the containers.
Create a .env
file in the root directory to set environment variables:
QDRANT_HOST=localhost
QDRANT_PORT=6333
COHERE_API_KEY=your_cohere_api_key
OPENAI_API_KEY=your_openai_api_key
Use PDM to start the FastAPI server:
pdm run uvicorn app.main:app --host 0.0.0.0 --port 8000
This command runs your FastAPI application, which can be accessed at http://localhost:8000.
Dramatiq is used for background tasks. Start the workers using:
pdm run dramatiq app.workers
This command starts the Dramatiq worker processes for handling background tasks.
- ❌ If PDM install fails:
pdm install --no-lock
- 🔄 If Redis container fails:
docker restart redis_container
- 💡 Check logs with:
docker logs redis_container