| """ |
| 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() |
| |
| |
| client = get_langchain_client(default_complexity='complex', enable_monitoring=False) |
| print("β LangChain client initialized") |
| |
| |
| planner = PlannerAgent(llm_client=client) |
| print("β PlannerAgent created with LangChain") |
| print() |
| |
| |
| 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() |
| |
| |
| 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()) |
|
|