FakeNews_Detector / debug_rag_setup.py
NLong's picture
Upload 12 files
b5fb8d2 verified
#!/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()