File size: 1,968 Bytes
9681c5d 2754790 4dc95d7 2754790 e7d283a 2754790 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
#!/usr/bin/env python3
"""
TheDataGuy Chat - Main Entry Point
This script serves as the main entry point for the TheDataGuy Chat application.
It provides a command-line interface to run the app and update the vector database.
"""
import os
import sys
import argparse
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
def main():
"""Main function to run the application or update blog data"""
parser = argparse.ArgumentParser(description="TheDataGuy Chat - RAG-powered blog assistant")
# Define commands
subparsers = parser.add_subparsers(dest="command", help="Command to run")
# Run app command
run_parser = subparsers.add_parser("run", help="Run the chat application")
run_parser.add_argument("--host", default="0.0.0.0", help="Host to bind to")
run_parser.add_argument("--port", type=int, default=7860, help="Port to bind to")
# Update vector store command
update_parser = subparsers.add_parser("update", help="Update the vector database")
update_parser.add_argument("--force", action="store_true", help="Force recreation of the vector store")
# Parse arguments
args = parser.parse_args()
# Handle commands
if args.command == "run":
# Import here to avoid circular imports
import chainlit as cl
os.system(f"chainlit run py-src/app.py --host {args.host} --port {args.port}")
elif args.command == "update":
# Import here to avoid loading heavy dependencies if not needed
from py_src.pipeline import create_vector_database
force_flag = "--force-recreate" if args.force else ""
print(f"Updating vector database (force={args.force})")
create_vector_database(force_recreate=args.force)
else:
# Show help if no command provided
parser.print_help()
return 1
return 0
if __name__ == "__main__":
sys.exit(main())
|