Add src/loader.py
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
"""Utility to load all .txt files from a directory into the knowledge base.
|
||||||
|
|
||||||
|
This module is useful for initializing the vector store before interacting with the agent.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from .vector_store import KnowledgeBase
|
||||||
|
|
||||||
|
kb = KnowledgeBase()
|
||||||
|
|
||||||
|
def load_directory(directory: str) -> None:
|
||||||
|
"""Load all .txt files from *directory* into the knowledge base.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
directory: str
|
||||||
|
Path to the directory containing text files.
|
||||||
|
"""
|
||||||
|
kb.load_from_directory(directory)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description="Load text files into the knowledge base")
|
||||||
|
parser.add_argument("directory", type=str, help="Directory with .txt files")
|
||||||
|
args = parser.parse_args()
|
||||||
|
load_directory(args.directory)
|
||||||
|
print("Loading completed.")
|
||||||
Reference in New Issue
Block a user