How mohitvverma/rag_with_agents works
Main Components
• Ingestion Module: Represented by components in the "domains/injestion" directory (e.g., doc_loader, models, vector_db_utils). This module is responsible for accepting and processing documents for storage.
• Storage/Vector Database: Although the code doesn’t physically implement the database, conceptually include a component to represent where processed documents will be stored (a vector database such as Pinecone).
• Retrieval Module: Located in "domains/retreival" (e.g., chat_handler, initialize_memory, rag_util, prompts) and the nested "pinecone_doc_retreival" folder. This component is in charge of querying the vector database and fetching relevant documents.
• Agents Module: Found in "domains/agents" (e.g., models, prompt, routes, tools). This part implements a multi-agent architecture to process incoming queries and generate responses using the retrieved data.
• API Layer: The REST endpoints and WebSocket interaction documented in the README are handled by files like "domains/agents/routes.py", "domains/injestion/routes.py", "domains/retreival/routes.py", and the main entry points "service.py" and "domains/app.py".
Relationships and Data Flow
• The flow starts with the Ingestion API (POST /ingest): Documents are uploaded and processed.
• Processed documents are then stored in the vector database.
• When a query is received (via the Run Agents API endpoint or WebSocket), the Retrieval module queries the vector database, selects relevant documents, and passes them along.
• The Agents module takes over by analyzing the query in conjunction with the retrieved documents and generates a response using LLMs.
• Finally, the result is sent back to the client via API responses or real-time WebSocket streams.
Architectural Patterns and Design Principles
• Modular / Layered Architecture: Notice how each functional component (ingestion, storage, retrieval, generation) is encapsulated in its own module.
• Separation of Concerns: Each module is responsible for a specific part of the workflow, making the system easier to manage and extend.
• Integration via APIs: REST and WebSocket interfaces are used to expose the system’s functionalities, underscoring a clear client-service separation.
Technologies and Frameworks
• Python 3.8+ environment and dependencies (listed in requirements.txt).
• Use of AI/ML libraries for LLM interactions (implied by the generation task, even if not explicitly noted in the file tree).
• Vector database integration (suggested by modules interacting with Pinecone).
• Each Component: Create nodes for “Ingestion Module”, “Vector Database”, “Retrieval Module”, “Agents Module”, and “API Layer”.