Spaces:
Running
Running
File size: 2,299 Bytes
b091b2c |
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 |
#!/usr/bin/env python3
"""
Test the updated tool selection to ensure we use CryptoCompare/Etherscan instead of CoinGecko
"""
import asyncio
import sys
import os
# Add src to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from src.agent.research_agent import Web3ResearchAgent
async def test_tool_selection():
"""Test that the system prioritizes CryptoCompare and Etherscan over CoinGecko"""
print("π§ͺ Testing tool selection...")
agent = Web3ResearchAgent()
if not agent.enabled:
print("β Agent not enabled")
return False
# Check which tools are initialized
tool_names = [tool.name for tool in agent.tools]
print(f"π οΈ Available tools: {tool_names}")
# Verify CoinGecko is not in tools (since no API key)
if 'coingecko_data' in tool_names:
print("β οΈ CoinGecko tool is still initialized - this may cause API failures")
else:
print("β
CoinGecko tool properly skipped (no API key)")
# Verify we have the working tools
expected_tools = ['cryptocompare_data', 'etherscan_data', 'defillama_data', 'chart_data_provider']
working_tools = [tool for tool in expected_tools if tool in tool_names]
print(f"β
Working tools available: {working_tools}")
# Test a simple query
try:
print("\nπ Testing Bitcoin price query...")
result = await agent.research_query("Analyze Bitcoin price trends", use_gemini=True)
if result['success']:
print("β
Query successful!")
print(f"π Result preview: {result['result'][:200]}...")
print(f"π§ Tools used: {result.get('metadata', {}).get('tools_used', 'N/A')}")
return True
else:
print(f"β Query failed: {result.get('error', 'Unknown error')}")
return False
except Exception as e:
print(f"β Test failed with exception: {e}")
return False
async def main():
success = await test_tool_selection()
if success:
print("\nπ Tool selection test passed!")
return 0
else:
print("\nβ Tool selection test failed!")
return 1
if __name__ == "__main__":
exit_code = asyncio.run(main())
sys.exit(exit_code)
|