Download tests/unit/test_planner_migration.py from MHamdan/SPARKNET: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/spaces/MHamdan/SPARKNET/resolve/main/tests/unit/test_planner_migration.py
- Command line
-
hf download hf://spaces/MHamdan/SPARKNET/tests/unit/test_planner_migration.py
-
curl -L -o test_planner_migration.py https://huggingface.co/spaces/MHamdan/SPARKNET/resolve/main/tests/unit/test_planner_migration.py
1.85 kB
| """ | |
| Test migrated PlannerAgent with LangChain | |
| """ | |
| import asyncio | |
| from src.llm.langchain_ollama_client import get_langchain_client | |
| from src.agents.planner_agent import PlannerAgent | |
| from src.workflow.langgraph_state import ScenarioType | |
| async def test_planner_migration(): | |
| print("Testing PlannerAgent migration to LangChain...") | |
| print() | |
| # Initialize LangChain client | |
| client = get_langchain_client(default_complexity='complex', enable_monitoring=False) | |
| print("β LangChain client initialized") | |
| # Create PlannerAgent | |
| planner = PlannerAgent(llm_client=client) | |
| print("β PlannerAgent created with LangChain") | |
| print() | |
| # Test 1: Template-based planning | |
| print("Test 1: Template-based planning (patent_wakeup)") | |
| task_graph = await planner.decompose_task( | |
| task_description="Analyze dormant patent US123456 for commercialization", | |
| scenario="patent_wakeup" | |
| ) | |
| print(f" β Generated {len(task_graph.subtasks)} subtasks") | |
| print(f" β Execution order: {len(task_graph.get_execution_order())} parallel layers") | |
| print(f" β Graph valid: {task_graph.validate()}") | |
| print() | |
| # Test 2: LangChain-based planning | |
| print("Test 2: LangChain-based planning (custom task)") | |
| try: | |
| task_graph2 = await planner.decompose_task( | |
| task_description="Research market opportunities for AI-powered drug discovery platform" | |
| ) | |
| print(f" β Generated {len(task_graph2.subtasks)} subtasks via LangChain") | |
| print(f" β Graph valid: {task_graph2.validate()}") | |
| except Exception as e: | |
| print(f" Note: LangChain planning requires Ollama running") | |
| print(f" Error: {e}") | |
| print() | |
| print("β All PlannerAgent migration tests passed!") | |
| if __name__ == "__main__": | |
| asyncio.run(test_planner_migration()) | |