-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteractive_test.py
More file actions
62 lines (49 loc) Β· 1.85 KB
/
interactive_test.py
File metadata and controls
62 lines (49 loc) Β· 1.85 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
Interactive Test Script for RAG System
This allows you to test the system with your own questions.
"""
from simple_search import SimpleSearchRAG
import sys
def main():
"""Interactive test of the RAG system."""
print("π€ Interactive RAG Test")
print("=" * 50)
# Initialize RAG system
rag = SimpleSearchRAG(document_dir="documents")
if not rag.documents:
print("β No documents loaded!")
return
print(f"β
Loaded {len(rag.documents)} documents")
print(f"π Documents: {[doc['filename'] for doc in rag.documents]}")
print("\nπ‘ Try these sample questions:")
print(" - 'artificial intelligence'")
print(" - 'machine learning'")
print(" - 'neural networks'")
print(" - 'deep learning'")
print(" - 'computer vision'")
print("\nType 'quit' to exit")
print("-" * 50)
while True:
try:
question = input("\nβ Your question: ").strip()
if question.lower() in ['quit', 'exit', 'q']:
print("π Goodbye!")
break
if not question:
continue
# Show what documents we're searching
print(f"π Searching in {len(rag.documents)} documents...")
# Get results
result = rag.ask_question(question, top_k=3)
if result['sources']:
print(f"β
Found {len(result['sources'])} relevant sources")
else:
print("β No relevant sources found")
print("π‘ Try different keywords or simpler terms")
except KeyboardInterrupt:
print("\nπ Goodbye!")
break
except Exception as e:
print(f"β Error: {e}")
if __name__ == "__main__":
main()