Views
No views yet
1git clone <repository-url>
2cd DHIGROWTH_RAG1python -m venv venv
2source venv/Scripts/activate1python3 -m venv venv
2source venv/bin/activatepip install -r requirements.txtpython src/embed_loader.pydata/dhigrowth_final_rag_ft.jsonl./embeddingsDHIGROWTH_RAG/
│
├── app.py # FastAPI application
├── config.py # Configuration module
├── requirements.txt # Python dependencies
├── README.md # This file
│
├── models/ # LLM model files
│ └── Dhi_Qwen2P5_0_5B_Q4_K_M.gguf
│
├── data/ # Training/knowledge base data
│ └── dhigrowth_final_rag_ft.jsonl
│
├── embeddings/ # ChromaDB persistent storage
│ └── (auto-generated)
│
└── src/ # Source code
├── embed_loader.py # Vector database creation
├── retriever.py # Document retrieval module
├── llm_wrapper.py # LLM model wrapper
├── rag_pipeline.py # Main RAG pipeline
└── logger_config.py # Logging configurationconfig.py. Create a .env file in the project root:1# Model paths
2MODEL_PATH=./models/Dhi_Qwen2P5_0_5B_Q4_K_M.gguf
3EMBEDDINGS_PATH=./embeddings
4DATA_PATH=./data/dhigrowth_final_rag_ft.jsonl
5
6# Embedding model
7EMBEDDING_MODEL=all-MiniLM-L6-v2
8
9# Generation settings
10MAX_TOKENS=400
11TOP_K=3
12
13# LLM settings
14N_CTX=4096
15TEMPERATURE=0.0
16TOP_P=1.0
17
18# Server settings
19PORT=8001MODEL_PATH: Path to the GGUF model fileEMBEDDINGS_PATH: ChromaDB storage directoryDATA_PATH: Path to JSONL knowledge base fileEMBEDDING_MODEL: SentenceTransformer model nameMAX_TOKENS: Maximum tokens for LLM generationTOP_K: Number of documents to retrieveN_CTX: Context window sizeTEMPERATURE: Sampling temperature (0.0 = deterministic)TOP_P: Nucleus sampling parameterPORT: Server port (default: 8001)1# Activate virtual environment
2source venv/Scripts/activate # Windows: venv\Scripts\activate
3
4# Start the server
5uvicorn app:app --reload --port 8001http://localhost:80011from src.rag_pipeline import rag_chat
2
3# Ask a question
4answer = rag_chat("What services does Dhigrowth offer?")
5print(answer)GET /1{
2 "message": "Dhigrowth RAG Chatbot API",
3 "version": "1.0.0",
4 "endpoints": {
5 "health": "/health",
6 "ask": "/ask (POST)"
7 }
8}GET /health1{
2 "status": "healthy",
3 "service": "Dhigrowth RAG Chatbot",
4 "version": "1.0.0"
5}POST /ask1{
2 "question": "What services does Dhigrowth offer?"
3}1{
2 "question": "What services does Dhigrowth offer?",
3 "answer": "Dhigrowth provides website development, application development, digital marketing, SEO improvement, business automation, and custom business growth strategies."
4}400 Bad Request: Invalid input422 Unprocessable Entity: Validation error500 Internal Server Error: Server error1curl -X POST http://localhost:8001/ask \
2 -H "Content-Type: application/json" \
3 -d '{"question": "How do I book a consultation?"}'1import requests
2
3response = requests.post(
4 "http://localhost:8001/ask",
5 json={"question": "What services does Dhigrowth offer?"}
6)
7print(response.json())1fetch("http://localhost:8001/ask", {
2 method: "POST",
3 headers: {
4 "Content-Type": "application/json",
5 },
6 body: JSON.stringify({
7 question: "What services does Dhigrowth offer?",
8 }),
9})
10 .then((response) => response.json())
11 .then((data) => console.log(data));python -c "from src.rag_pipeline import rag_chat; print(rag_chat('What services does Dhigrowth offer?'))"python -c "from app import app; from fastapi.testclient import TestClient; client = TestClient(app); print(client.get('/health').json())"TEST_RESULTS.md for detailed test results.uvicorn app:app --reload --port 8001uvicorn app:app --host 0.0.0.0 --port 8001 --workers 4Dockerfile:1FROM python:3.11-slim
2
3WORKDIR /app
4
5COPY requirements.txt .
6RUN pip install --no-cache-dir -r requirements.txt
7
8COPY . .
9
10EXPOSE 8001
11
12CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8001"]1docker build -t dhigrowth-rag .
2docker run -p 8001:8001 dhigrowth-ragDhi_Qwen2P5_0_5B_Q4_K_M.gguf is in the models/ directorypython src/embed_loader.py to create the vector databaseuvicorn app:app --port 8001dhigrowth_rag.log for detailed error information.