add cli
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
import sys
|
||||||
|
from rag_tools import add_to_knowledge_base, search_knowledge_base
|
||||||
|
|
||||||
|
def run_cli():
|
||||||
|
print("RAG CLI. Commands: /add <title> <content>, /search <query>, /quit")
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
line = input(">>> ")
|
||||||
|
except EOFError:
|
||||||
|
break
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
if line.startswith("/quit"):
|
||||||
|
break
|
||||||
|
if line.startswith("/add"):
|
||||||
|
parts = line.split(maxsplit=2)
|
||||||
|
if len(parts) < 3:
|
||||||
|
print("Usage: /add <title> <content>")
|
||||||
|
continue
|
||||||
|
title, content = parts[1], parts[2]
|
||||||
|
print(add_to_knowledge_base(content, title))
|
||||||
|
elif line.startswith("/search"):
|
||||||
|
query = line[len("/search"):].strip()
|
||||||
|
print(search_knowledge_base(query))
|
||||||
|
else:
|
||||||
|
print("Unknown command")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
run_cli()
|
||||||
Reference in New Issue
Block a user