langchain loading documents into vector storage

This commit is contained in:
2026-02-03 20:52:08 +03:00
parent 762ed89843
commit 8d7e39a603
5 changed files with 299 additions and 42 deletions

View File

@@ -9,10 +9,10 @@ def setup_logging():
# Create logs directory if it doesn't exist
logs_dir = Path("logs")
logs_dir.mkdir(exist_ok=True)
# Add file logging with rotation
logger.add("logs/dev.log", rotation="10 MB", retention="10 days")
@click.group()
def cli():
@@ -28,5 +28,31 @@ def ping():
click.echo("pong")
@cli.command(name="enrich", help="Load documents from data directory and store in vector database")
@click.option('--data-dir', default="../../../data", help="Path to the data directory")
@click.option('--collection-name', default="documents", help="Name of the vector store collection")
def enrich(data_dir, collection_name):
"""Load documents from data directory and store in vector database"""
logger.info(f"Starting enrichment process for directory: {data_dir}")
try:
# Import here to avoid circular dependencies
from vector_storage import initialize_vector_store
from enrichment import run_enrichment_process
# Initialize vector store
vector_store = initialize_vector_store(collection_name=collection_name)
# Run enrichment process
run_enrichment_process(vector_store, data_dir=data_dir)
logger.info("Enrichment process completed successfully!")
click.echo("Documents have been successfully loaded into the vector store.")
except Exception as e:
logger.error(f"Error during enrichment process: {str(e)}")
click.echo(f"Error: {str(e)}")
if __name__ == "__main__":
cli()