File size: 3,986 Bytes
59de368
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env python3
"""
Test script for the new Senior Research Analyst feature
"""

def test_imports():
    """Test that all new components can be imported"""
    try:
        from agents import ResearchAnalystAgent, MasterOrchestrator
        print("βœ… ResearchAnalystAgent imported successfully")
        
        from config import Config
        print("βœ… Config imported successfully")
        
        from utils.prompts import PromptManager
        print("βœ… PromptManager imported successfully")
        
        return True
    except ImportError as e:
        print(f"❌ Import error: {e}")
        return False

def test_agent_initialization():
    """Test that the ResearchAnalystAgent can be initialized"""
    try:
        from agents import ResearchAnalystAgent
        from config import Config
        
        agent = ResearchAnalystAgent(name='TestResearchAgent', model=Config.OPENAI_MODEL)
        print("βœ… ResearchAnalystAgent initialized successfully")
        return True
    except Exception as e:
        print(f"❌ Agent initialization error: {e}")
        return False

def test_research_prompts():
    """Test that research prompts are available"""
    try:
        from utils.prompts import PromptManager
        
        pm = PromptManager()
        all_prompts = pm.get_all_prompts()
        research_prompts = [pid for pid, prompt in all_prompts.items() if prompt.get('category') == 'research']
        
        print(f"βœ… Found {len(research_prompts)} research prompts:")
        for prompt_id in research_prompts:
            prompt_info = all_prompts[prompt_id]
            print(f"   - {prompt_id}: {prompt_info['name']}")
        
        return len(research_prompts) > 0
    except Exception as e:
        print(f"❌ Research prompts test error: {e}")
        return False

def test_orchestrator_integration():
    """Test that the orchestrator can handle research targets"""
    try:
        from agents import ResearchAnalystAgent, MasterOrchestrator
        from config import Config
        
        # Create agents dict with research agent
        agents = {
            "research": ResearchAnalystAgent(name="ResearchAnalystAgent", model=Config.OPENAI_MODEL)
        }
        
        orchestrator = MasterOrchestrator(agents=agents)
        print("βœ… MasterOrchestrator initialized with research agent")
        return True
    except Exception as e:
        print(f"❌ Orchestrator integration error: {e}")
        return False

def main():
    """Run all tests"""
    print("πŸ§ͺ Testing Senior Research Analyst Feature Implementation")
    print("=" * 60)
    
    tests = [
        ("Import Tests", test_imports),
        ("Agent Initialization", test_agent_initialization),
        ("Research Prompts", test_research_prompts),
        ("Orchestrator Integration", test_orchestrator_integration),
    ]
    
    results = []
    for test_name, test_func in tests:
        print(f"\nπŸ” Running {test_name}...")
        result = test_func()
        results.append((test_name, result))
    
    print("\n" + "=" * 60)
    print("πŸ“Š Test Results Summary:")
    
    all_passed = True
    for test_name, result in results:
        status = "βœ… PASS" if result else "❌ FAIL"
        print(f"   {status} {test_name}")
        if not result:
            all_passed = False
    
    print("\n" + "=" * 60)
    if all_passed:
        print("πŸŽ‰ All tests passed! Senior Research Analyst feature is ready.")
        print("\nπŸš€ New Features Available:")
        print("   - Senior Research Analyst Agent with R&D pipeline focus")
        print("   - 4 specialized research prompts")
        print("   - Dedicated research analysis tab in UI")
        print("   - Streaming support for research analysis")
        print("   - Export functionality for research results")
    else:
        print("⚠️  Some tests failed. Please check the implementation.")
    
    return all_passed

if __name__ == "__main__":
    main()