mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-23 18:06:38 +08:00
5.9 KiB
5.9 KiB
LangRAG Knowledge Base
Use this reference when validating LangRAG creation, document ingestion, retrieval, and local-agent RAG behavior.
Setup
- Install
langbot-team/LangRAGfrom Marketplace if/api/v1/knowledge/engineshas no LangRAG engine. - Confirm
LANGBOT_BACKEND_URL/api/v1/knowledge/enginescontains plugin idlangbot-team/LangRAG. - Prefer local Chroma embedding for offline/free tests:
- Provider requester:
chroma-embedding - Embedding model name:
chroma-all-MiniLM-L6-v2
- Provider requester:
Important: a Chroma embedding entry must exist under embedding_models. A model accidentally created as an LLM model will appear in the wrong model selector and will not satisfy LangRAG's embedding-model field.
Parser Golden Case
Use cases/langrag-parser-golden-e2e.yaml when validating the LangRAG + GeneralParsers integration on the current master worktree.
Fixture:
fixtures/rag/parser-golden.html
Golden intent:
- Start LangBot from
LANGBOT_REPO, which should point at the master worktree for this run. - Build and install/update local
LANGBOT_RAG_PLUGIN_REPOandLANGBOT_PARSER_PLUGIN_REPO. - Upload the HTML fixture and select GeneralParsers when the parser chooser is shown.
- Confirm retrieval returns
aurora-parser-rag-9137,GeneralParsers,LangRAG, and the Markdown table header| Parser field | Golden value |. - Confirm logs show LangRAG used external pre-parsed content instead of the internal fallback parser.
Local install pitfall:
- If GeneralParsers fails while installing
PyMuPDF>=1.24.0, readtroubleshooting/plugin-dependency-install-offline.yaml. - The golden case can continue after the active LangBot master venv can
import fitzandpython -m pip install --dry-run 'PyMuPDF>=1.24.0'reports the requirement is satisfied.
Browser Flow
- Open
LANGBOT_FRONTEND_URL. - Navigate to
Knowledge. - Create a knowledge base.
- Select engine
LangRAG. - Select embedding model
chroma-all-MiniLM-L6-v2or another known working embedding model. - Keep the index type as
Chunkfor smoke/regression tests. - Upload a small sentinel document.
- Wait until the document row status is
Completed. - Open
Retrieve Testand query for the sentinel.
Recommended fixture:
fixtures/rag/sentinel-doc.txt
Pass Criteria
- The created knowledge base appears in the sidebar.
- The uploaded document reaches
Completed. - Retrieve Test returns the uploaded document with the sentinel text.
- Browser console has no unexpected errors.
Document Lifecycle Acceptance
- Keep the public Host file UUID from upload/listing when calling file deletion. Core stores the engine-returned
document_idseparately in the server-ownedengine_document_idcolumn and sends it to the engine; do not overwrite the Host UUID or put this mapping in creation settings. - Wait for the ingestion task to finish before deletion. Pending/processing files reject deletion to avoid losing the tracking row while an upstream document is still being created.
- Verify both the Host file-list readback and absence of the sentinel upstream. Core only removes its row after an explicit engine
True;False, missing configuration, runtime errors, and unconfirmed absence remain failures with the row retained. A connector'sFalseis not proof that the upstream document is absent. - Failed ingestion with an acknowledged engine ID retains it for cleanup. Historical failed files with no mapping still use the Host UUID fallback, subject to confirmed deletion. New unacknowledged/malformed responses are
interrupted, not confirmed failures. interruptedmeans Core cannot establish the remote ingestion outcome (cancellation, disconnect, timeout, lost acknowledgement, or abandoned pending/processing work). It is not proof of failure, successful ingestion, or remote quiescence. Core preserves the tracking row, any known engine ID, and its source upload; retention cleanup also protects pending/processing/interrupted uploads.- Runtime loading and normal file listing recover abandoned rows to
interrupted. Reloading a KB object must preserve genuinely live tasks. Delayed old tasks cannot replay interrupted rows or overwrite them with completion; an observed late engine ID is still retained. - File deletion and whole-KB deletion reject interrupted work with operator guidance. Do not bypass this guard merely because the task list is empty or the Host restarted: the old SDK/plugin action may still write. There is deliberately no automatic retry, force-delete, or claim of a remote cancellation fence.
- Recovery procedure: preserve a DB/storage backup; identify the exact Workspace, KB, Host file UUID, engine ID (if known), and installation; inspect that plugin/upstream operation; establish that the old operation has stopped or settled; then have an operator reconcile the confirmed upstream outcome and exact mapping before cleanup or re-upload. Never invent an opaque upstream ID or blindly set
failedto unlock deletion. Lost historical uploads/IDs cannot be reconstructed by this change. Automatic cleanup of arbitrary connector orphans is outside this recovery contract. - SDK ingest/delete action signatures and envelopes are unchanged; old SDKs use the same conservative interrupted fallback. Existing acknowledged asynchronous-engine responses retain the legacy Host completion semantics (Host ingestion acknowledgement, not a guarantee that the upstream index is ready).
- Migration
0025_rag_document_identityleaves historical mappings null: it cannot reconstruct IDs previously discarded, nor restore already-deleted Host rows. Those require separately authorized investigation/recovery. Downgrading removes the mapping column and loses these identities; back up before rollback.
Local-Agent RAG Check
After retrieval passes:
- Open the target pipeline.
- In
Configuration > AI, add the knowledge base toKnowledge Bases. - Save.
- Open
Debug Chat. - Ask for the sentinel.
- Confirm the bot response contains the exact sentinel.