atharva / test_deployment.py
ATHARVA
Add application file
984ac15
#!/usr/bin/env python3
"""
πŸš€ Quick Test Script for GAIA Agent
Tests basic functionality before deployment
"""
import os
import sys
def test_imports():
"""Test all required imports"""
print("πŸ” Testing imports...")
try:
import gradio as gr
print("βœ… Gradio")
except ImportError as e:
print(f"❌ Gradio: {e}")
return False
try:
import requests
print("βœ… Requests")
except ImportError as e:
print(f"❌ Requests: {e}")
return False
try:
import pandas as pd
print("βœ… Pandas")
except ImportError as e:
print(f"❌ Pandas: {e}")
return False
try:
from dotenv import load_dotenv
print("βœ… Python-dotenv")
except ImportError as e:
print(f"❌ Python-dotenv: {e}")
return False
try:
from langchain_core.messages import HumanMessage
print("βœ… LangChain Core")
except ImportError as e:
print(f"❌ LangChain Core: {e}")
return False
return True
def test_environment():
"""Test environment setup"""
print("\nπŸ” Testing environment...")
# Load environment
from dotenv import load_dotenv
load_dotenv()
# Check API keys
api_keys = {
"GROQ_API_KEY": os.getenv("GROQ_API_KEY"),
"GOOGLE_API_KEY": os.getenv("GOOGLE_API_KEY"),
"TAVILY_API_KEY": os.getenv("TAVILY_API_KEY"),
}
has_llm_key = False
for key, value in api_keys.items():
status = "βœ… Set" if value else "❌ Missing"
print(f" {key}: {status}")
if key in ["GROQ_API_KEY", "GOOGLE_API_KEY"] and value:
has_llm_key = True
if not has_llm_key:
print("⚠️ WARNING: No LLM API key found!")
return False
return True
def test_agent_import():
"""Test agent import"""
print("\nπŸ€– Testing agent import...")
try:
from atharva.agent import build_graph
print("βœ… Agent module imported successfully")
return True
except ImportError as e:
print(f"❌ Agent import failed: {e}")
return False
except Exception as e:
print(f"❌ Agent error: {e}")
return False
def test_app_import():
"""Test app import"""
print("\nπŸ“± Testing app import...")
try:
# Test if we can import the app components
import atharva.app as app
print("βœ… App module imported successfully")
return True
except ImportError as e:
print(f"❌ App import failed: {e}")
return False
except Exception as e:
print(f"❌ App error: {e}")
return False
def main():
"""Run all tests"""
print("πŸš€ GAIA Agent Deployment Test")
print("=" * 50)
tests = [
("Import Test", test_imports),
("Environment Test", test_environment),
("Agent Import Test", test_agent_import),
("App Import Test", test_app_import),
]
results = []
for test_name, test_func in tests:
try:
result = test_func()
results.append((test_name, result))
except Exception as e:
print(f"❌ {test_name} crashed: {e}")
results.append((test_name, False))
# Summary
print("\n" + "=" * 50)
print("πŸ“Š Test Results Summary:")
passed = sum(1 for _, result in results if result)
total = len(results)
for test_name, result in results:
status = "βœ… PASS" if result else "❌ FAIL"
print(f" {test_name}: {status}")
print(f"\n🎯 Score: {passed}/{total} tests passed")
if passed == total:
print("πŸŽ‰ All tests passed! Ready for deployment!")
return 0
else:
print("⚠️ Some tests failed. Please fix issues before deployment.")
return 1
if __name__ == "__main__":
sys.exit(main())