Spaces:
Runtime error
Runtime error
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) |