$ show Cinnamon/kotaemon
Kotaemon is a production-grade Retrieval-Augmented Generation (RAG) application for chatting with documents. It provides a full-stack Gradio web UI with user management, document indexing (PDF, DOCX, HTML, images, web URLs), hybrid retrieval (vector + full-text), reranking, and multi-step reasoning pipelines (simple QA, question decomposition, ReWOO agent). The architecture is a monolith split into two Python libraries: `kotaemon` (core components: embeddings, LLMs, indices, storages, loaders, agents) and `ktem` (application layer: UI pages, reasoning pipelines, database models, settings). It supports multiple LLM providers (OpenAI, Azure, Anthropic, Gemini, Cohere, Ollama, LlamaCpp), embedding models, vector stores (Chroma, LanceDB, Milvus, Qdrant), and document stores. The system is highly configurable via environment variables and a settings UI. While primarily an application, it includes data/research elements such as document loaders, OCR pipelines, graph-based indexing (GraphRAG, LightRAG, NanoGraphRAG), and a training dataset for question rephrasing.
The LLM identified 5 files worth highlighting for reuse:
Defines `BaseComponent`, `Node`, `Param`, and `lazy` for composing typed, cacheable pipeline steps with dependency injection. This is the foundational abstraction for all indexing, retrieval, and reasoning pipelines. It is self-contained, well-documented, and could be extracted as a standalone pipeline framework.
Implements `PromptTemplate` with placeholder validation, partial population, concatenation, and serialization. Unlike simple f-strings, it validates that all placeholders are provided and supports merging multiple templates. Reusable in any LLM application.
Provides `ModelPool` – a generic registry for LLMs, embeddings, and reranking models with CRUD operations, default selection, and singleton caching. The same pattern is reused across three managers (LLM, Embedding, Reranking) with minimal duplication. Could be extracted as a reusable model management library.
Defines `CiteEvidence` and `Citation` Pydantic models for structured citation handling, including evidence text, page numbers, and relevance scores. Used across all QA pipelines to produce verifiable answers. The model design is clean and could be reused in any document QA system.
Implements `MCPTool` that wraps Model Context Protocol (MCP) tools as agent-compatible tools. Handles tool discovery, parameter conversion, and result formatting. Demonstrates a clean adapter pattern for integrating external tool ecosystems into agent frameworks.