How marella/chatdocs works
Core Components
• User Interfaces:
• CLI Interface (invoked via commands like “chatdocs chat” and “chatdocs add”)
• Web UI (started with “chatdocs ui” and exposed on localhost:5000)
• Document Processing:
• Document Ingestion Module – “add.py” handles adding documents (e.g., parsing various file types).
• Data Storage – Though not directly shown as a directory (mentioned as “db”), the processed documents and embeddings are persisted.
• AI Model Management:
• Model Downloading – “download.py” allows users to download AI models.
• Model Adapter/Controllers – Modules such as “llms.py”, “embeddings.py”, and “vectorstores.py” abstract interactions with different model types (CTransformers, HuggingFace, GPTQ).
• Configuration Engine:
• Config Module (“config.py”) reads the “chatdocs.yml” and merges user options with defaults.
• Orchestration/Processing Chains:
• “chains.py” likely coordinates the processing workflow (retrieval, embedding, querying).
• Utilities & Logging:
• “utils.py” for common functions.
• “logger.py” for logging purposes.
• Supporting Modules:
• “chat.py” – Handles the actual conversational logic.
• “ui.py” – Manages the web user interface interactions.
• “main.py” – Acts as an entry point for the application.
Relationships and Data Flow
• How user commands (CLI or Web UI) invoke the main application logic.
• How the configuration manager (via “chatdocs.yml”) supplies runtime options.
• How the document ingestion module sends processed documents to the vector-store and embedding modules.
• How the chat (conversation) module interacts with the underlying AI model controllers (LLMs, CTransformers, HuggingFace) to process queries.
• The download module’s connection to external repositories for fetching pretrained models.
Architectural Patterns and Design Principles
• Separation of Concerns: Each module (e.g., configuration, downloading, document ingestion, model interfacing) is clearly separated.
• Scalability: The processing chain (document ingestion → embeddings → vector storage → query processing) can be scaled or replaced.
• Extensibility: The configuration file (chatdocs.yml) serves as a central point of customization, indicating how new options (like GPU support) integrate into the overall process.
Technology and Frameworks
• Underlying Python modules for AI, such as integration with PyTorch and specific libraries (CTransformers, HuggingFace).
• The presence of a web server implies use of a framework to serve the UI (likely a lightweight web framework).