Spaces:
Sleeping
Sleeping
| #!/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() | |