From 8e9477e19f5865d5adb0f27adfbe98d98777ea37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Fri, 5 Jun 2026 13:07:12 +0000 Subject: [PATCH] Delete obsolete cli.py --- cli.py | 90 ---------------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 cli.py diff --git a/cli.py b/cli.py deleted file mode 100644 index d6caee1..0000000 --- a/cli.py +++ /dev/null @@ -1,90 +0,0 @@ -"""Interactive CLI for the RAG agent. - -The CLI supports the following commands: - -* ``/add `` – Load all .txt/.md files from *dir* into Qdrant. -* ``/search `` – Run the agent on *query* and print the answer. -* ``/quit`` – Exit the program. - -The vector store is created on first use and persisted in -``./qdrant_db``. -""" - -import os -from pathlib import Path - -# Load environment variables (e.g., TAVILY_API_KEY) -from dotenv import load_dotenv -load_dotenv() - -# Local modules -from .vector_store import create_vectorstore, load_documents -from .agent import create_agent -from . import tools - -# --------------------------------------------------------------------------- -# Global state -# --------------------------------------------------------------------------- -VECTORSTORE = None -AGENT = None - -# --------------------------------------------------------------------------- -# Helper functions -# --------------------------------------------------------------------------- - -def init_vectorstore() -> None: - global VECTORSTORE - if VECTORSTORE is None: - VECTORSTORE = create_vectorstore() - # Expose the store to the tools module so that the decorated - # functions can access it via the global name ``vectorstore``. - tools.vectorstore = VECTORSTORE - -def init_agent() -> None: - global AGENT - if AGENT is None: - AGENT = create_agent() - -def add_documents(directory: str) -> None: - init_vectorstore() - load_documents(directory, VECTORSTORE) - -def run_query(query: str) -> None: - init_agent() - # The agent expects a dictionary with the key ``input``. - result = AGENT.invoke({"input": query}) - print("\nAnswer:\n", result) - -# --------------------------------------------------------------------------- -# CLI loop -# --------------------------------------------------------------------------- - -def main() -> None: - print("RAG Agent CLI. Type '/quit' to exit.") - while True: - try: - line = input("> ") - except (EOFError, KeyboardInterrupt): - print("\nBye!") - break - if not line: - continue - if line.strip() == "/quit": - print("Bye!") - break - if line.startswith("/add "): - _, dir_path = line.split(" ", 1) - dir_path = dir_path.strip() - if not os.path.isdir(dir_path): - print(f"{dir_path} is not a directory.") - continue - add_documents(dir_path) - print("Documents added.") - elif line.startswith("/search "): - _, query = line.split(" ", 1) - run_query(query.strip()) - else: - print("Unknown command. Use /add, /search, or /quit.") - -if __name__ == "__main__": - main() \ No newline at end of file