File size: 4,636 Bytes
a1492aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env python3
"""
πŸ” GAIA Agent Diagnostic Test
Quick test to diagnose why the agent isn't answering questions
"""

import os
import sys
from gaia_system import BasicAgent, EnhancedMultiModelGAIASystem

def test_basic_agent():
    """Test the BasicAgent with simple questions"""
    print("πŸ§ͺ Testing BasicAgent...")
    
    try:
        # Initialize agent
        agent = BasicAgent()
        print("βœ… Agent initialized successfully")
        
        # Test simple questions
        test_questions = [
            "What is 2 + 2?",
            "What is the capital of France?",
            "How many days are in a week?",
            "What color is the sky?"
        ]
        
        for i, question in enumerate(test_questions, 1):
            print(f"\nπŸ“ Test {i}: {question}")
            try:
                response = agent(question)
                print(f"πŸ€– Response: '{response}'")
                print(f"πŸ“ Length: {len(response)} characters")
                
                if not response or response.strip() == "":
                    print("❌ Empty response!")
                elif "Unable to" in response or "Error" in response:
                    print("⚠️ Error response detected")
                else:
                    print("βœ… Got non-empty response")
                    
            except Exception as e:
                print(f"❌ Error: {e}")
                
    except Exception as e:
        print(f"❌ Failed to initialize agent: {e}")
        return False
        
    return True

def test_enhanced_system():
    """Test the EnhancedMultiModelGAIASystem directly"""
    print("\nπŸ§ͺ Testing EnhancedMultiModelGAIASystem...")
    
    try:
        # Test with HF token if available
        hf_token = os.getenv('HF_TOKEN')
        if hf_token:
            print(f"βœ… Found HF_TOKEN: {hf_token[:10]}...")
        else:
            print("⚠️ No HF_TOKEN found - using fallback mode")
            
        system = EnhancedMultiModelGAIASystem(hf_token=hf_token)
        print("βœ… Enhanced system initialized")
        
        # Test simple query
        question = "What is 5 + 3?"
        print(f"\nπŸ“ Testing: {question}")
        
        response = system.query_with_tools(question)
        print(f"πŸ€– Raw response: '{response}'")
        
        # Test fallback
        fallback = system._fallback_response(question)
        print(f"πŸ›‘οΈ Fallback response: '{fallback}'")
        
        # Test answer extraction
        if response:
            extracted = system._extract_final_answer(response)
            print(f"✨ Extracted answer: '{extracted}'")
            
        return True
        
    except Exception as e:
        print(f"❌ Enhanced system error: {e}")
        import traceback
        traceback.print_exc()
        return False

def test_model_availability():
    """Test which AI models are available"""
    print("\nπŸ” Testing model availability...")
    
    try:
        system = EnhancedMultiModelGAIASystem()
        
        print(f"πŸ“Š Available models: {len(system.clients)}")
        for name, client_info in system.clients.items():
            provider = client_info.get('provider', 'Unknown')
            priority = client_info.get('priority', 999)
            print(f"  - {name} (Priority: {priority}, Provider: {provider})")
            
        if system.model_priority:
            print(f"🎯 Top priority model: {system.model_priority[0]}")
        else:
            print("❌ No models in priority list!")
            
        return True
        
    except Exception as e:
        print(f"❌ Model availability error: {e}")
        return False

def main():
    """Run all diagnostic tests"""
    print("πŸš€ GAIA Agent Diagnostic Tests\n")
    
    # Test basic functionality
    test1 = test_basic_agent()
    test2 = test_enhanced_system() 
    test3 = test_model_availability()
    
    print("\nπŸ“Š Test Summary:")
    print(f"  BasicAgent: {'βœ… PASS' if test1 else '❌ FAIL'}")
    print(f"  Enhanced System: {'βœ… PASS' if test2 else '❌ FAIL'}")
    print(f"  Model Availability: {'βœ… PASS' if test3 else '❌ FAIL'}")
    
    if not any([test1, test2, test3]):
        print("\n❌ All tests failed! Check dependencies and configuration.")
        return False
    elif not test1:
        print("\n⚠️ BasicAgent failed - this is the issue for GAIA submissions!")
        return False
    else:
        print("\nβœ… Core functionality working - issue might be elsewhere")
        return True

if __name__ == "__main__":
    success = main()
    sys.exit(0 if success else 1)