File size: 752 Bytes
e92d49a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import annotations
import argparse
from rag.chain import answer

def main() -> None:
    parser = argparse.ArgumentParser(description="Run the FAQ RAG chatbot locally.")
    parser.add_argument("question", nargs="?", help="The question to answer from the FAQ knowledge base.")
    args = parser.parse_args()

    if args.question:
        print(answer(args.question))
        return
    
    try:
        while True:
            q = input("Question (type 'exit' to quit): ").strip()
            if not q:
                continue
            if q.lower() in {"exit", "quit"}:
                break
            print(answer(q))
    except (KeyboardInterrupt, EOFError):
        print("\nGoodbye")


if __name__ == "__main__":
    main()