From 9f28f871536c7e8e05f159eb6ac518516abf04a4 Mon Sep 17 00:00:00 2001 From: balabanovan530 <175+balabanovan530@noreply.localhost> Date: Tue, 2 Jun 2026 11:46:37 +0000 Subject: [PATCH] Add main.py --- main.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..1906577 --- /dev/null +++ b/main.py @@ -0,0 +1,41 @@ +import os +import argparse +from dotenv import load_dotenv +from vectorstore import VectorStore +from agent import get_agent + + +def main(): + load_dotenv() + parser = argparse.ArgumentParser(description="RAG Agent CLI") + parser.add_argument("--docs_dir", type=str, default=None, help="Directory with documents to load") + args = parser.parse_args() + + vectorstore = VectorStore() + if args.docs_dir: + if os.path.isdir(args.docs_dir): + print(f"Loading documents from {args.docs_dir}...") + vectorstore.add_documents(args.docs_dir) + print("Documents loaded and indexed.") + else: + print(f"Documents directory {args.docs_dir} does not exist.") + agent = get_agent(vectorstore) + + print("RAG Agent ready. Type your query or 'exit' to quit.") + try: + while True: + query = input("You: ") + if query.lower() in ("exit", "quit"): + print("Goodbye!") + break + try: + response = agent.run(query) + print(f"Agent: {response}") + except Exception as e: + print(f"Error: {e}") + except KeyboardInterrupt: + print("\nInterrupted. Exiting.") + + +if __name__ == "__main__": + main()