diff --git a/ansible/roles/rag/files/rag-ingest b/ansible/roles/rag/files/rag-ingest index 8c5e4e3..10a102a 100644 --- a/ansible/roles/rag/files/rag-ingest +++ b/ansible/roles/rag/files/rag-ingest @@ -19,6 +19,13 @@ COLLECTION = os.environ.get("RAG_COLLECTION", "funk-docs") VECTOR_DIM = 4096 CHUNK_MAX = 2000 +# Dossiers (relatifs à docs_dir) exclus de l'index : rapports auto-générés par +# hermes-auto-improve (méta-commentaires sur la doc, pas de la connaissance) — ils +# noyaient la vraie doc (~84% des points). Surchargeable via RAG_EXCLUDE (séparé par ":"). +EXCLUDE_DIRS = [ + p for p in os.environ.get("RAG_EXCLUDE", "hermes/builtin").split(":") if p +] + def _request(method, url, data=None): body = json.dumps(data).encode() if data is not None else None @@ -95,9 +102,15 @@ def point_id(file_path, section): def ingest(docs_dir): ensure_collection() + excluded = {os.path.normpath(os.path.join(docs_dir, p)) for p in EXCLUDE_DIRS} md_files = [] for root, dirs, files in os.walk(docs_dir): - dirs[:] = sorted(d for d in dirs if not d.startswith('.')) + # élague les dossiers cachés et exclus (ex. hermes/builtin) + dirs[:] = sorted( + d for d in dirs + if not d.startswith('.') + and os.path.normpath(os.path.join(root, d)) not in excluded + ) for f in sorted(files): if f.endswith('.md'): md_files.append(os.path.join(root, f))