This is a complete Retrieval-Augmented Generation (RAG) application that uses a local DeepSeek model (via API), LangGraph for agentic workflows, and PostgreSQL (pgvector) for vector storage.
- Full Stack RAG: End-to-end implementation from document ingestion to answer generation.
- Local/Remote Model Support: Configured to use DeepSeek API (compatible with OpenAI SDK).
- Vector Database: Uses PostgreSQL with
pgvectorfor efficient similarity search. - Agentic Workflow: Powered by LangGraph to handle complex queries and retrieval steps.
- Interactive UI: Built with Streamlit, featuring non-blocking background knowledge base updates.
- GPU Acceleration: Optimized for NVIDIA GPUs (CUDA 12.4) with CPU fallback.
- Python 3.10+
- PostgreSQL with
pgvectorextension installed. - NVIDIA GPU (Optional, but recommended for local embeddings).
- DeepSeek API Key (or compatible OpenAI-style API key).
-
Clone the repository (if applicable) or navigate to the project directory.
-
Install Dependencies:
pip install -r requirements.txt
-
Environment Setup:
- Ensure PostgreSQL is running.
- Create a database (e.g.,
rag_db) and enable the vector extension:CREATE EXTENSION vector;
- Set up your environment variables. You can export them in your shell or add them to the
start.shscript.
The application uses the following environment variables:
HF_ENDPOINT: Mirror for Hugging Face (e.g.,https://hf-mirror.com).DEEPSEEK_API_KEY: Your DeepSeek API key.DEEPSEEK_BASE_URL: Base URL for the API (e.g.,https://api.deepseek.com).
Use the provided helper script to start the application:
bash start.sh-
Initialize/Update Knowledge Base: If this is your first run, or if you have added new documents to the
data/folder (or root), run:python create_db.py
Note: You can also update the knowledge base directly from the Streamlit UI sidebar.
-
Run the Streamlit App:
export HF_ENDPOINT=https://hf-mirror.com streamlit run app.py
app.py: Main Streamlit application file. Handles UI and chat logic.create_db.py: Script to ingest documents and populate the vector database.rag_agent.py: Defines the LangGraph agent and retrieval logic.requirements.txt: Python dependencies.start.sh: Convenience script for launching the app.ARCHITECTURE.md: Detailed system architecture documentation.
- Torch/CUDA Errors: Ensure you have installed the correct version of PyTorch for your CUDA version.
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
- Database Connection: Check your PostgreSQL connection string in
create_db.pyandrag_agent.py.