How deepsense-ai/ragbits works
Project type and purpose
• This is a monorepo for “Ragbits,” an open-source, modular Python toolkit plus accompanying UI and CLI for building GenAI (RAG/chat) applications.
• It provides core building blocks (LLMs, embeddings, prompts, vector stores), higher-level modules (agents, document search, evaluation, guardrails), a CLI (ragbits), and a React-based Chat UI.
File structure
• Top‐level directories and files:
• packages/… – each subfolder (ragbits-core, ragbits-chat, ragbits-document-search, ragbits-evaluate, ragbits-agents, ragbits-guardrails, ragbits-cli) is a standalone Python package exposing one or more entrypoints (APIs/CLI commands).
• ui/ – front-end application (TypeScript/React/Vite).
• scripts/ – monorepo helper scripts (release, package generation).
• .github/ – CI/CD: workflows for tests, docs, PyPI.
• pyproject.toml, mkdocs.yml – root build/configuration.
• Each Python package under packages/ follows:
• src/ragbits/<component> – module code (interfaces, sub‐packages)
• tests/ – unit/integration tests
• pyproject.toml + README.md + CHANGELOG.md
• The UI folder has its own package.json, Vite config, contexts, components, plugin system.
README for additional insights
• Describes:
• Core features: LLM abstraction, vector store adapters, prompts.
• Optional modules: document search (ingest, retrieval), agents, evaluation pipelines, guardrails (moderation).
• A CLI for interactive use and orchestration.
• A Chat UI leveraging the underlying Python API via an HTTP or local host interface.
a. Main components
• Ragbits-Core (LLMs, embeddings, prompts, vector stores)
• Ragbits-Document-Search (ingestion, retrieval pipelines)
• Ragbits-Agents (agent orchestration layer)
• Ragbits-Evaluate (evaluation pipelines: dataloaders, metrics, optimizer)
• Ragbits-Guardrails (safety/moderation wrappers)
• Ragbits-Chat (API server, chat interface, persistence, UI assets)
• Ragbits-CLI (shell tool integrating all modules)
• Frontend UI (React app served by Ragbits-Chat)
• External services:
– LLM providers (OpenAI, local, LiteLLM)
– Vector stores (Qdrant, PgVector, In-Memory)
– Data sources (S3, GCS, Azure, Git, Web)
– Observability (OpenTelemetry, Grafana)
b. Relationships & interactions
• UI ↔ Ragbits-Chat API: HTTP/WebSocket for chat sessions.
• CLI ↔ Underlying Python modules via command‐line commands.
• Ragbits-Chat ↔ Ragbits-Core (calls LLM, embeddings).
• Document-Search ↔ Core embedding + vector store adapters.
• Agents layer orchestrates prompt → LLM → action → memory storage.
• Evaluate pipelines orchestrate Document-Search or Chat flows for metrics collection.
• Guardrails wrap calls to LLM to enforce safety policies.
• All modules may read/write from persistence (SQL, file) managed by Ragbits-Chat or provided by user.
• Observability hooks (traces, metrics) plugged into core and CLI.
c. Architectural patterns & design principles
• Modular, plugin-based architecture – each component is installable independently, discoverable via entry points.
• Adapter pattern – for LLMs, embeddings, vector stores, parsers, enrichers.
• Pipeline chaining – ingestion strategies, retrieval re-rankers, evaluation pipelines.
• Observer pattern – telemetry integration, event hooks.
• Separation of concerns – core vs. higher-level modules vs. UI/CLI.
d. Key technologies
• Python + Pydantic for API models
• AsyncIO for concurrency in ingestion, LLM calls
• Entry points for CLI and modular plugin discovery
• React, Vite, TypeScript for chat UI
• OpenTelemetry for tracing
• Ray for distributed ingestion (optional)