Add cli_client.py

This commit is contained in:
2026-05-28 12:26:34 +00:00
parent ff3f360241
commit be9a3770ee
+27
View File
@@ -0,0 +1,27 @@
"""Interactive CLI client for the RAG agent."""
import argparse
from typing import Any
from .rag_tools import search_knowledge_base, add_to_knowledge_base
from .agent import executor
def main() -> None:
parser = argparse.ArgumentParser(description="RAG CLI client.")
parser.add_argument("command", choices=["/add", "/search", "/quit"], help="Command to execute")
parser.add_argument("--text", default="", help="Text for /add or query for /search")
args = parser.parse_args()
if args.command == "/add":
result = add_to_knowledge_base(args.text)
print(result)
elif args.command == "/search":
results = search_knowledge_base(args.text, max_results=5)
for text, score in results:
print(f"{score:.4f}: {text[:200]}...")
else: # /quit
print("Goodbye!")
if __name__ == "__main__":
main()