Spaces:
Sleeping
Sleeping
| #!/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()) | |