File size: 1,741 Bytes
932c83b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""🧪 Quick Agent Test - Verify build_graph function works"""
import os
os.environ["GOOGLE_API_KEY"] = "AIzaSyDZX6kuggMpFDlMSzCw2bq3hIuQq1bLXe4"

try:
    from agent import build_graph, test_agent
    from langchain_core.messages import HumanMessage
    
    print("🧪 Testing Agent Initialization...")
    
    # Test 1: Build graph with Google provider
    print("\n1️⃣ Testing build_graph with Google provider...")
    try:
        graph = build_graph("google")
        if graph:
            print("✅ Graph built successfully!")
            
            # Test 2: Simple question
            print("\n2️⃣ Testing simple question...")
            test_question = "What is 15 + 27?"
            messages = [HumanMessage(content=test_question)]
            
            result = graph.invoke({"messages": messages})
            
            if result and "messages" in result and result["messages"]:
                answer = result["messages"][-1].content
                print(f"Question: {test_question}")
                print(f"Answer: {answer}")
                print("✅ Agent working correctly!")
            else:
                print("❌ No valid response from agent")
                
        else:
            print("❌ Graph is None - build_graph failed")
            
    except Exception as e:
        print(f"❌ Error during testing: {e}")
        import traceback
        traceback.print_exc()
    
    print("\n🎯 If you see '✅ Agent working correctly!' above, the fix is successful!")
    print("📤 Deploy this fix to HF Space to resolve the 0% score issue.")
    
except ImportError as e:
    print(f"❌ Import error: {e}")
    print("This might indicate missing dependencies or import issues.")