PDF_analyst / test_research_feature.py
JatsTheAIGen's picture
Add Senior Research Analyst feature with R&D pipeline focus - New ResearchAnalystAgent for extracting high-value insights - 4 specialized research prompts for experiments, prototypes, and product decisions - Enhanced UI with dedicated research analysis tab - Streaming support and export functionality - Non-breaking integration preserving all existing workflows
59de368
#!/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()