From 744d97b85793b3a674d5e637194b12524550b769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Fri, 5 Jun 2026 13:03:29 +0000 Subject: [PATCH] Delete obsolete src/loader.py --- src/loader.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/loader.py diff --git a/src/loader.py b/src/loader.py deleted file mode 100644 index 951c31f..0000000 --- a/src/loader.py +++ /dev/null @@ -1,37 +0,0 @@ -"""Utility to load all text files from a directory into the knowledge base. - -Usage: - python -m src.loader /path/to/docs -""" - -from __future__ import annotations - -import argparse -import pathlib -from typing import Iterable - -from .vector_store import KnowledgeBase - -def _iter_text_files(dir_path: pathlib.Path) -> Iterable[pathlib.Path]: - """Yield all .txt files in *dir_path* recursively.""" - for p in dir_path.rglob("*.txt"): - yield p - -def load_directory(dir_path: pathlib.Path, kb: KnowledgeBase) -> None: - """Load each text file into the knowledge base. - - The file name (without extension) is used as the document title. - """ - for file_path in _iter_text_files(dir_path): - title = file_path.stem - content = file_path.read_text(encoding="utf-8") - kb.add_document(title=title, content=content) - print(f"Loaded {file_path} as '{title}'") - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Load documents into the RAG knowledge base") - parser.add_argument("directory", type=str, help="Path to directory containing .txt files") - args = parser.parse_args() - kb = KnowledgeBase() - load_directory(pathlib.Path(args.directory), kb) - print("Loading complete.") \ No newline at end of file