Files
task-6a02e23da6fe2e4ac16acf65/cli.py
T
2026-05-12 20:01:18 +00:00

20 lines
695 B
Python

import sys
from agent import executor
if __name__ == "__main__":
print("RAG Agent CLI. Commands: /add <title> <file>, /search <query>, /quit")
while True:
line = input("> ")
if line.startswith("/quit"):
break
if line.startswith("/add"):
_, title, file = line.split(maxsplit=2)
with open(file, "r", encoding="utf-8") as f:
text = f.read()
print(executor.invoke({"input": f"add {title} {text}"}))
elif line.startswith("/search"):
_, query = line.split(maxsplit=1)
print(executor.invoke({"input": f"search {query}"}))
else:
print("Unknown command")