RustyRAG is a production-grade RAG (Retrieval-Augmented Generation) API server written in Rust, designed for sub-200ms time-to-first-token. It provides a complete pipeline: document ingestion (PDF, DOCX, PPTX, XLSX, HTML, TXT, ZIP) via Docling with layout-aware extraction, OCR, table recognition, and optional vision-model image descriptions; hybrid search using Milvus (dense HNSW vectors + BM25 sparse with Reciprocal Rank Fusion); cross-encoder reranking via Jina Reranker v3; and streaming LLM responses from Groq or Cerebras. The server exposes REST endpoints for document upload, semantic search, RAG chat (both full response and SSE streaming), collection backup, and an evaluation benchmark runner. The architecture follows a clean layered pattern: Actix-web handlers in `src/handlers/` orchestrate business logic, services in `src/services/` encapsulate external API clients (Milvus, embeddings, reranker, Docling, LLM), and schemas in `src/schemas/` define request/response types with OpenAPI annotations via utoipa. The Rust binary is a single self-contained server; GPU-accelerated sidecars (embeddings, reranker, Docling) run as Docker containers. Configuration is environment-driven with sensible defaults. Key entry points are the HTTP API at `/api/v1/` (Swagger UI at `/swagger-ui/`) and a built-in chat UI at `/static/chat.html`. The primary data flow for a RAG query is: embed user query → fire concurrent dense and BM25 searches in Milvus → merge via RRF → rerank top candidates → build context prompt → stream LLM response with source citations and timing metadata. The system is designed for low latency and high accuracy, with benchmark results showing 94.5% pass rate with reranker at ~279ms TTFT.
This repository provides a Python library for converting web pages into text optimized for Large Language Model (LLM) input. It fetches HTML content using Playwright (headless browser) and processes it to extract meaningful text while preserving structural information like tables, links, and images in a text format. The core processing logic converts HTML tables to markdown, handles image and link preservation (or removal), and strips unnecessary tags (script, style) to reduce noise. The library is designed as a preprocessing step before feeding web content to LLMs for tasks such as data extraction or summarization. It includes three main modules: HTML fetching, HTML processing, and a combined convenience function.