Lecteur Markdown

llm_rag Documentation › LLM_RAG_DOCUMENTATION_EN

Llm Rag Documentation En

Feature: LLM RAG #

Retrieval-Augmented Generation (RAG) engine. Allows users to build a personal knowledge base that is automatically injected as context during LLM conversations. The engine splits documents into chunks, indexes them and retrieves them via full-text search.

Installation and Configuration

Via FTP: Upload the llm_rag/ directory into /plugins/.

Via package manager: Select llm_rag from the available plugins list.

Paths:

  • Main plugin: /plugins/llm_rag/llm_rag.php
  • Configuration: /plugins/llm_rag/conf/llm_rag.conf.inc.php
  • Library: /plugins/llm_rag/lib/llm_rag.lib.inc.php
  • AJAX handler: /plugins/llm_rag/handlers/llm_rag.mod.php
  • JavaScript: /plugins/llm_rag/js/llm_rag.js
  • CSS: /plugins/llm_rag/css/llm_rag.css

Configuration parameters (llm_rag.conf.inc.php):

| Parameter | Default | Description |

|---|---|---|

| CHUNK_SIZE | 500 | Chunk size (in tokens) |

| CHUNK_OVERLAP | 50 | Overlap between chunks |

| TOP_K_CHUNKS | 5 | Number of chunks injected into context |

| MIN_RELEVANCE_SCORE | 0.6 | Minimum relevance score |

| USE_EMBEDDINGS | false | Currently uses keyword matching |

| ALLOWED_SOURCE_TYPES | text, markdown, url, file, manual | Accepted source types |

| ENABLE_AEGIS_WARNINGS | true | Integration with the aegis_corpus plugin |

| WARNING_INJECTION_THRESHOLD | 0.6 | Injection detection threshold |

| MIN_QUERY_LENGTH | 20 | Minimum query length (characters) |

| MIN_QUERY_WORDS | 5 | Minimum number of words |

| MIN_MEANINGFUL_RATIO | 0.6 | Meaningful word ratio |

Required SQL tables:

  • llm_rag_sources — source metadata (source_id, user_id, title, source_type, content, url, is_global)
  • llm_rag_chunks — indexed chunks (chunk_id, source_id, chunk_index, chunk_text, chunk_tokens, metadata)
  • llm_rag_user_config — per-user settings (user_id, auto_inject, top_k, min_relevance)
  • llm_rag_usage — usage log (optional)

Usage

Source management #

Users add documents from:

  • plain text — direct copy-paste
  • markdown.md file
  • URL — page content is fetched
  • uploaded filetxt, md, etc.
  • manual — structured entry

Each source is automatically split into overlapping chunks.

Sources created by an administrator (is_global = 1) are accessible to all users.

User settings #

Each user can adjust via the interface:

  • Enable/disable automatic RAG
  • Number of chunks (top_k)
  • Minimum relevance score

Hooks and Entry Points

AJAX handler (llm_rag.mod.php) #

| Action | Description |

|---|---|

| list_sources | Paginated source list (20 per page) |

| get_source | Source detail by ID |

| add_source | Create a source (POST) |

| delete_source | Delete a source |

| get_chunks | Chunks for a source |

| get_config | User RAG configuration |

| update_config | Update preferences |

| get_stats | Statistics (sources, chunks, 30-day usage) |

| test_rag | Retrieval test with a query |

| test_query | Simple test endpoint |

Dependencies

  • Beamreactor\Database\SQL
  • Beamreactor\Sanitizer\Parser
  • Beamreactor\LLMConnector\ContextHelper — integration with the llm_connector plugin
  • Plugin aegis_corpus (optional) — injection detection in retrieved chunks