Add interactive CLI client with /add, /search, /quit commands
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Interactive test CLI client for RAG agent with /add, /search, /quit commands."""
|
||||||
|
|
||||||
|
from rag_tools import search_knowledge_base, add_to_knowledge_base
|
||||||
|
|
||||||
|
|
||||||
|
PROMPT = "> "
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("=== RAG Knowledge Base CLI ===")
|
||||||
|
print("Commands: /add <title> | /search <query> | /quit")
|
||||||
|
print("-" * 40)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
user_input = input(PROMPT).strip()
|
||||||
|
except
|
||||||
|
SÑQ\œ›Ü‹Ù^X›Ø\™[�\œ�\
|
||||||
|
N‚ˆš[�
|
||||||
|
—�žYHHŠBˆœ™XZ‚ˆYˆ›Ý\Ù\—Ú[œ]‚ˆÛÛ�[�YB‚ˆYˆ\Ù\—Ú[œ]œÝ\�ÝÚ]
|
||||||
|
‹ÜÙX\˜ÚŠN‚ˆ]Y\žHH\Ù\—Ú[œ]΋ÜÙX\˜ÚŽ…Ò .strip()
|
||||||
|
if not query:
|
||||||
|
print("Use: /search <your_query>")
|
||||||
|
continue
|
||||||
|
print("\nSearching...")
|
||||||
|
result = search_knowledge_base(query)
|
||||||
|
print(f"\n{result}\n")
|
||||||
|
|
||||||
|
elif user_input.startswith("/add "):
|
||||||
|
title_and_content = user_input[5:].strip()
|
||||||
|
if "|" in title_and_content:
|
||||||
|
parts = title_and_content.split("|", 1)
|
||||||
|
title = parts[0].strip()
|
||||||
|
content = parts[1].strip()
|
||||||
|
else:
|
||||||
|
title = title_and_content
|
||||||
|
content = input("Enter content: ").strip()
|
||||||
|
|
||||||
|
if not content:
|
||||||
|
print("Error: content cannot be empty.")
|
||||||
|
continue
|
||||||
|
|
||||||
|
result = add_to_knowledge_base(content, title)
|
||||||
|
print(f\n{result}\n")
|
||||||
|
|
||||||
|
elif user_input == "/quit":
|
||||||
|
print("Bye!")
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f"Unknown command: {user_input}")
|
||||||
|
print("Available: /add <title>|<content>, /search <query>, /quit")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user