File size: 1,980 Bytes
65703d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Quick test to verify response cleaning works properly
"""

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_response_cleaning():
    """Test that responses are properly cleaned of LangChain metadata"""
    print("πŸ§ͺ Testing response cleaning...")
    
    agent = Web3ResearchAgent()
    
    if not agent.enabled:
        print("❌ Agent not enabled")
        return False
    
    try:
        print("πŸ“Š Testing simple Bitcoin price query...")
        result = await agent.research_query("What is Bitcoin current price?", use_gemini=True)
        
        if result['success']:
            response_content = result['result']
            print(f"βœ… Query successful!")
            print(f"πŸ“ˆ Response type: {type(response_content)}")
            print(f"πŸ“„ Response preview: {response_content[:200]}...")
            
            # Check if response contains LangChain metadata (bad)
            if "additional_kwargs" in str(response_content) or "response_metadata" in str(response_content):
                print("❌ Response contains LangChain metadata - not properly cleaned")
                return False
            else:
                print("βœ… Response properly cleaned - no LangChain metadata found")
                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_response_cleaning()
    if success:
        print("\nπŸŽ‰ Response cleaning test passed!")
        return 0
    else:
        print("\n❌ Response cleaning test failed!")
        return 1

if __name__ == "__main__":
    exit_code = asyncio.run(main())
    sys.exit(exit_code)