File size: 2,692 Bytes
b5fb8d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python3
"""

Debug RAG system setup

"""

def debug_rag_setup():
    """Debug the RAG system setup step by step"""
    print("πŸ”§ Debugging RAG System Setup")
    print("=" * 40)
    
    try:
        # Step 1: Test imports
        print("1. Testing imports...")
        from rag_news_manager import RAGNewsManager
        print("βœ… RAGNewsManager imported successfully")
        
        # Step 2: Create manager instance
        print("2. Creating RAG manager...")
        manager = RAGNewsManager()
        print("βœ… RAG manager created")
        
        # Step 3: Test authentication
        print("3. Testing authentication...")
        if manager.authenticate():
            print("βœ… Authentication successful")
        else:
            print("❌ Authentication failed")
            return False
        
        # Step 4: Test folder setup
        print("4. Testing folder setup...")
        if manager.setup_rag_folder():
            print("βœ… Folder setup successful")
            print(f"   Folder ID: {manager.rag_folder_id}")
        else:
            print("❌ Folder setup failed")
            return False
        
        # Step 5: Test file setup
        print("5. Testing file setup...")
        if manager.setup_rag_file():
            print("βœ… File setup successful")
            print(f"   File ID: {manager.rag_file_id}")
        else:
            print("❌ File setup failed")
            return False
        
        # Step 6: Test data loading
        print("6. Testing data loading...")
        data = manager.load_rag_data()
        if data:
            print("βœ… Data loading successful")
            print(f"   Total entries: {data.get('metadata', {}).get('total_entries', 0)}")
        else:
            print("❌ Data loading failed")
            return False
        
        # Step 7: Test statistics
        print("7. Testing statistics...")
        stats = manager.get_rag_statistics()
        if stats:
            print("βœ… Statistics successful")
            print(f"   Total entries: {stats['total_entries']}")
            print(f"   Folder ID: {stats.get('folder_id', 'None')}")
            print(f"   File ID: {stats.get('file_id', 'None')}")
        else:
            print("❌ Statistics failed")
            return False
        
        print("\nπŸŽ‰ All tests passed! RAG system is working correctly.")
        return True
        
    except Exception as e:
        print(f"❌ Error during debugging: {e}")
        import traceback
        traceback.print_exc()
        return False

if __name__ == "__main__":
    debug_rag_setup()