|
|
|
|
|
|
|
|
|
""" |
|
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_dotenv() |
|
|
|
def main(): |
|
"""Main function to run the application or update blog data""" |
|
parser = argparse.ArgumentParser(description="TheDataGuy Chat - RAG-powered blog assistant") |
|
|
|
|
|
subparsers = parser.add_subparsers(dest="command", help="Command to run") |
|
|
|
|
|
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_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") |
|
|
|
|
|
args = parser.parse_args() |
|
|
|
|
|
if args.command == "run": |
|
|
|
import chainlit as cl |
|
os.system(f"chainlit run py-src/app.py --host {args.host} --port {args.port}") |
|
|
|
elif args.command == "update": |
|
|
|
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: |
|
|
|
parser.print_help() |
|
return 1 |
|
|
|
return 0 |
|
|
|
if __name__ == "__main__": |
|
sys.exit(main()) |
|
|