atharva / quick_test.py
ATHARVA
πŸ”§ CRITICAL FIX: Resolve LangChain agent initialization issue
932c83b
"""πŸ§ͺ 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.")