How bigmb/mb_rag works
Main Components
• RAG and Embedding Module (mb_rag/rag/embeddings.py): Responsible for generating text embeddings, interfacing with vector stores (like Chroma), and producing retrievers for context-aware queries.
• Chatbot Module (mb_rag/chatbot): Contains basic chat implementations and chain integrations (using LangChain) for conversation management.
• Agents Module (mb_rag/agents): Implements specialized agents such as a web browser agent that supports additional features (possibly using langgraph).
• Utility Functions (mb_rag/utils): Includes helpers for document extraction, PDF processing, and particularly image processing utilities (e.g., bounding_box.py for image annotation).
• Example Scripts and Jupyter Notebooks (examples/): Provide usage examples showing various use cases (chatbot interactions, embedding generation, image processing, etc.).
• Configuration and Environment Setup: Files like .env.example, Dockerfile, and pyproject.toml indicate deployment and configuration aspects.
Interactions and Relationships
– From the Chatbot Module, show interactions with the RAG Module where embeddings are generated and retrieval is performed from a vector store.
– For image-related capabilities, display how client images are processed via the Utilities (bounding_box.py) that interact with external image processing APIs (e.g., Google Generative AI) and return processed images.
– Highlight external dependencies such as LLM providers (OpenAI, Anthropic, Google, Ollama, Groq) and vector stores (Chroma) to illustrate integration points.
Architecture Patterns and Design Principles
– Modularity: The project is broken into clear sub-packages (rag, chatbot, agents, utils) which follow separation of concerns.
– Extensibility: The use of multiple model providers with a unified interface (ModelFactory) suggests a pluggable, abstracted design enabling easy swapping of underlying technologies.
– Layered Structure: A common pattern of having core logic (model factories, chaining logic) that interfaces with utility modules and external services.
– Use of standardized configuration and environment management (e.g., .env files) to support deployment.
Relevant Technologies
– Python, along with dependencies from langchain (core, community, openai, anthropic, google-genai, ollama).
– Image processing libraries like Pillow and OpenCV (as indicated in the optional dependencies).
– External vector store, for example, ChromaDB.
– Containerization support (Dockerfile) to indicate potential deployment in Docker.