29 lines
843 B
Python
29 lines
843 B
Python
"""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.") |