How guilhermevaz8/rag_taac works
Project Type and Purpose
• This is a full-stack Retrieval-Augmented Generation (RAG) system written in Python.
• Purpose: Ingest user-uploaded documents, index them into vector/text stores (Qdrant, OpenSearch), then answer natural-language queries by retrieving relevant passages and calling an LLM (via LLMSherpa).
File-Structure Analysis
• Top-level:
• app.py – main Flask/FastAPI(?) server that drives upload, query routes and renders templates/index.html.
• templates/index.html – minimal front-end UI for document upload and Q&A.
• haystack_components/ – custom pipeline modules:
– documents_pipeline (Splitter.py, classifiers.py, save_stores.py)
– askLLM/GPT.py – wrapper for calling the LLM.
– prompt_re_eng (llm.py, new_search.py) – prompt construction and query-based re-ranking.
– pipeline.py – orchestrates ingestion & query pipelines.
• Configuration: requirements.txt; Docker invoked externally for Qdrant, OpenSearch, LLMSherpa.
Key Components
a. Frontend
• Web UI (templates/index.html) served by app.py
b. Backend / API Layer
• app.py exposes endpoints:
• /upload → calls ingestion pipeline
• /query → calls retrieval & generation pipeline
c. Ingestion Pipeline
• Splitter (chunks documents)
• Classifiers (metadata tagging)
• save_stores (embeddings → Qdrant, text → OpenSearch)
d. Retrieval & Generation Pipeline
• new_search (construct search queries over OpenSearch)
• vector search (Qdrant)
• prompt_re_eng.llm (assemble context + prompt)
• askLLM.GPT (call LLMSherpa service to generate answer)
e. External Services / Data Stores
• Qdrant (vector store)
• OpenSearch (text store)
• LLMSherpa (LLM inference service)
f. Orchestration
• haystack_components/pipeline.py coordinates both ingestion and query flows.
Component Relationships and Data Flow
• User → Frontend (upload/query) → Backend (app.py)
• Upload: Backend → Ingestion Pipeline → Qdrant & OpenSearch
• Query: Backend → Retrieval Pipeline → Qdrant + OpenSearch → Prompt Re-engineering → LLMSherpa → Backend → Frontend → User
• Docker containers host Qdrant, OpenSearch, LLMSherpa; Backend connects over HTTP/REST ports.
Architectural Patterns
• Pipeline pattern: clear separation between ingestion and query pipelines.
• Microservices: external services (Qdrant, OpenSearch, LLMSherpa) are containerized and communicate via REST/gRPC.
• MVC-style separation: UI (View), app.py (Controller), haystack_components & external stores (Model).
Final Checklist
• All components clearly named.
• Related modules (haystack_components sub-directories) within a “Pipeline” container.