test_agent.py•1.18 kB
#!/usr/bin/env python3
"""
Test script for the LangGraph Agent with MCP Tools
"""
import asyncio
import os
from dotenv import load_dotenv
from langgraph_agent import SimpleAgentApp
load_dotenv()
async def test_agent():
"""Test the LangGraph agent with various queries"""
print("Testing LangGraph Agent with MCP Tools")
print("=" * 50)
# Check environment variables
if not os.getenv("OPENAI_API_KEY"):
print("ERROR: OPENAI_API_KEY not found. Please set it in your .env file")
return
# Create the app
app = SimpleAgentApp()
# Test queries
test_queries = [
"Roll 1d20",
"What is the stock price of Apple?",
"Search for information about Python programming",
]
for i, query in enumerate(test_queries, 1):
print(f"\nTest {i}: {query}")
print("-" * 30)
try:
result = await app.process_query(query)
print(f"SUCCESS: Test {i} completed successfully")
except Exception as e:
print(f"ERROR: Test {i} failed: {e}")
print()
if __name__ == "__main__":
asyncio.run(test_agent())