No description
  • Python 95.8%
  • Nix 2.9%
  • Shell 1.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Basti n00b0ss 945585ee2e nix: fix llama-index-readers-file missing pandas dep properly
Previous attempt (764d4b0) added pandas to the env, but the failing
check runs inside the readers-file package build itself: nixpkgs lists
pandas in pythonRelaxDeps but omits it from the package's inputs, so
pythonRuntimeDepsCheck rejects the wheel. Fix the package via
overrideAttrs adding pandas to propagatedBuildInputs (override with
propagatedBuildInputs recursed infinitely because pandas depends on
the python package set).
2026-11-09 08:05:04 +00:00
docs docs: genericize hostnames/IPs in docs; add MIT license 2026-11-08 11:33:15 +00:00
tools docs: genericize hostnames/IPs in docs; add MIT license 2026-11-08 11:33:15 +00:00
.gitignore Initial scaffold: uv project with llama-index-core 2026-08-12 16:48:16 +02:00
AGENTS.md docs: rewrite AGENTS.md as generic project guide 2026-11-08 14:14:09 +00:00
flake.nix nix: fix llama-index-readers-file missing pandas dep properly 2026-11-09 08:05:04 +00:00
ingest.py docs: genericize hostnames/IPs in docs; add MIT license 2026-11-08 11:33:15 +00:00
LICENSE docs: genericize hostnames/IPs in docs; add MIT license 2026-11-08 11:33:15 +00:00
mcp_server.py mcp server: add agentic tools for Open WebUI (search_siemens_docs, get_document); Playwright MCP wired separately; rag_service prompt: language mirroring + URL citation guard; docs + AGENTS.md updated 2026-09-17 13:12:59 +02:00
module.nix nix: add flake with NixOS module for the rag-mcp service 2026-11-08 21:37:18 +00:00
pyproject.toml mcp server: add agentic tools for Open WebUI (search_siemens_docs, get_document); Playwright MCP wired separately; rag_service prompt: language mirroring + URL citation guard; docs + AGENTS.md updated 2026-09-17 13:12:59 +02:00
rag_service.py mcp server: add agentic tools for Open WebUI (search_siemens_docs, get_document); Playwright MCP wired separately; rag_service prompt: language mirroring + URL citation guard; docs + AGENTS.md updated 2026-09-17 13:12:59 +02:00
README.md docs: add README 2026-11-08 14:14:44 +00:00
retrieve.py retrieve: wire ivfflat.probes into pooled engine (per-connection GUC, default 100); docs: record 2026-09-12 HNSW->IVFFlat switch, rebuild-by-batch maintenance 2026-09-12 13:41:21 +02:00
shell.nix Add retrieval test with hybrid search and update progress 2026-09-08 18:53:47 +02:00
test_rag_service.py rag: expose model as siemens-rag, mask ornith upstream to LLM_MODEL 2026-09-10 09:39:53 +02:00
uv.lock mcp server: add agentic tools for Open WebUI (search_siemens_docs, get_document); Playwright MCP wired separately; rag_service prompt: language mirroring + URL citation guard; docs + AGENTS.md updated 2026-09-17 13:12:59 +02:00

Siemens RAG

Fully local Retrieval-Augmented Generation over technical Siemens industrial-automation documentation (bilingual DE/EN), built with LlamaIndex, llama.cpp and pgvector. No cloud APIs.

What you get

  • MCP server (:8998/mcp) — exposes the knowledge base as tools for any MCP client (e.g. Open WebUI's agentic mode):
    • search_siemens_docs(query, language="", top_k=8) — hybrid retrieval (pgvector + PostgreSQL full-text search, fused via RRF), language-aware
    • get_document(doc_id) — full chunk by DB id
  • RAG service (:8999) — OpenAI-compatible /v1/chat/completions endpoint that retrieves relevant chunks behind the scenes (streaming and non-streaming), so any OpenAI-compatible frontend can use it directly.

Architecture

MCP client (e.g. Open WebUI)        OpenAI-compatible clients
      │ tool calls                        │ chat requests
      ▼                                   ▼
mcp_server.py :8998/mcp         rag_service.py :8999/v1/chat/completions
      └────────────► retrieve.py ◄────────────┘
                      hybrid search (vector + FTS via RRF)
                            │
              ┌─────────────┼──────────────┐
              ▼             ▼              ▼
      llama.cpp :45757  PostgreSQL 16   llama.cpp :37679
      bge-m3 embeddings  + pgvector      LLM (chat generation)

Requirements

  • Python 3.13 + uv
  • PostgreSQL 16 with the pgvector extension
  • A llama.cpp server with a chat model (:37679) and an embedding model (bge-m3, :45757) — endpoints are env-configurable

Setup

git clone <this repo> && cd rag-system
uv sync

Point the services at your infrastructure via environment variables (see AGENTS.md for the full table):

export EMBEDDING_BASE_URL=http://127.0.0.1:45757/v1
export LLM_BASE_URL=http://127.0.0.1:37679/v1
export PG_DATABASE_URL=postgresql+psycopg2:///rag?host=/run/postgresql

Ingest documents

# subset for testing
uv run python ingest.py --batch-size 500 --limit 100

# full run (resumable with --no-drop)
uv run python ingest.py --batch-size 500

Expects scraped markdown documents with YAML frontmatter under data/ (see docs/ingest.md and docs/ingest_md_format.md for the format).

Run the services

uv run python mcp_server.py            # MCP server on :8998/mcp
uv run uvicorn rag_service:app --port 8999   # RAG service on :8999

Wire up Open WebUI

  • RAG service: Admin → Connections → OpenAI-compatible → http://127.0.0.1:8999/v1 (model siemens-rag)
  • MCP server: Admin → Integrations → MCP Streamable HTTP → http://127.0.0.1:8998/mcp

See docs/open_webui.md and docs/mcp_server.md for details.

Repository layout

Path Purpose
mcp_server.py MCP server (search / get_document tools)
rag_service.py FastAPI OpenAI-compatible RAG endpoint
retrieve.py shared retrieval engine (vector / FTS / hybrid RRF)
ingest.py batch ingestion: chunk → embed → pgvector
docs/ setup and operations guides
tools/ one-off maintenance scripts (OCR fixes, URL enrichment)

Notes

  • The services have no authentication — designed for a trusted local network. Do not expose them without adding auth.
  • Data is not included; the code expects the corpus under data/.
  • German retrieval quality was a design focus (language-aware FTS stemmers, bge-m3 multilingual embeddings).

License

MIT