How heniljshah/slackbot-agentic-rag works
Project Overview and Type
• The project is an AI agent focused on extracting answers from PDF documents using an agentic Retrieval-Augmented Generation (RAG) approach.
• It integrates with Slack (via a Slack integration module) for posting structured JSON responses.
• The solution emphasizes a custom retrieval-powered question answering flow using GPT (specifically a GPT-4o-mini model variant) and does not rely on pre-built chains from libraries like LangChain.
Analyzing the File Structure
• Top-Level Directories and Files:
• The “app” directory contains production code (main.py, slack_integration.py) for running the agent and handling Slack communication.
• The “POC” directory holds proof-of-concept materials, including:
▪ “docs” (project handbook, PDFs) that might explain internal workflow details.
▪ “notebooks” (for prototyping and experiments, e.g., main.py, prototype.ipynb) where the retrieval and integration logic was likely developed.
▪ “vdb” directory with a vector/database substructure (binary files, chroma.sqlite3) that underpins the retrieval component. This indicates that data is indexed, stored, and queried to enable answer extraction from large PDF documents.
• Other files such as readme.md and requirements.txt give context on dependencies and overall project goals.
Key Components
a. User Interface / Integration Layer:
• Slack Integration: Represents how users send questions via Slack.
• (Optionally) a command-line or web interface that might trigger the agent.
b. Agent Core:
• The main processing module (found in app/main.py) which functions as the controller.
• It handles receiving user questions, enhancing queries, and orchestrating the retrieval process.
• The agent uses custom logic to query the retriever multiple times (agentic RAG) to ensure completeness.
c. Retrieval Engine / Data Store:
• The vector database or indexed store (contents under POC/vdb, including binary and SQLite files) is used to retrieve relevant segments from the large PDF document.
• This could be abstracted as a “Retriever” component that interacts with the vectorized PDF representation.
d. AI Processing Module:
• Integration with OpenAI’s GPT model (GPT-4o-mini).
• The module formats enhanced queries with context from the retriever and receives processed answers.
Relationships and Data Flow
• A user question is input (via Slack or other channel) and is directed to the Slack integration component.
• The Slack integration module (in app/slack_integration.py) passes the question to the main processing module.
• The main module invokes the agentic RAG logic:
• It performs multiple iterations of retrieval by querying the Retriever.
• It formats each query with the necessary context for GPT processing.
• After obtaining a comprehensive answer, the module formats the response into structured JSON.
• The final output is sent back via the Slack integration module to the Slack channel.
• Internally, the retrieval component fetches data using the prebuilt vector store structure in the “POC/vdb” directory.
Architectural Patterns and Important Elements
• Modularity: The separation between the agent’s orchestration logic, retrieval component, and Slack integration.
• Iterative Querying (Agentic RAG): Multiple querying cycles to improve answer quality.
• Separation of Experimentation and Production: The “POC” directory provides proof-of-concept implementations while the “app” directory holds refined production code.
• Data Storage: Use of a custom vectorized data store (binary files and SQLite) to hold and index PDF content.